Plotting in Matlab: w vs z in (-1,1) Domain

In summary, the task is to plot the variables w and z, which are related by w=cos(n*acos(z)) and z=cos(acos(w)/n) for n = 1,2,3,4, over the domain (-1,1) in MATLAB. The suggested approach is to plot both variables as functions of each other and overlay the plots to show where both relations hold true. The coding process is straightforward, but the thought process behind it involves considering both variables as independent and dependent variables and finding a way to plot them accordingly.
  • #1
lee403
16
1

Homework Statement


(In Matlab) The variables w and z are related by w=cos(n*acos(z)) and z=cos(acos(w)/n) for n = 1,2,3,4 plot w vs z over domain (-1,1).

Homework Equations


w=cos(n*acos(z))
z=cos(acos(w)/n)

The Attempt at a Solution


First I tried to substitute z into w and thought since I have a function which calls itself I'd use a recursive function but I don't have the initial conditions. Then I thought that since the domain is (-1,1) and z would be plotted on that axis I could make z equal to an array with endpoints -1 and 1 and then plug that array in for w. Then I'd simply plot(z, w). The coding part is not difficult it's just the thought process behind it.
 
Physics news on Phys.org
  • #2
Normally, if you are asked to plot w vs. z over (-1, 1), you let one variable (say z) range from -1 to 1, and plot the other (w) as your dependent variable. In this case, I would try both ways.
Overlaying the two plots should show where both relations can be true at the same time.
 

Related to Plotting in Matlab: w vs z in (-1,1) Domain

1. What is the purpose of plotting w vs z in the (-1,1) domain in Matlab?

The purpose of plotting w vs z in the (-1,1) domain in Matlab is to visualize and analyze the relationship between two variables, w and z, within a specific range of values. This can help in understanding the behavior and trends of the variables and can aid in making predictions or drawing conclusions.

2. How do I plot w vs z in the (-1,1) domain in Matlab?

To plot w vs z in the (-1,1) domain in Matlab, you can use the "plot" function. First, create two arrays or vectors containing the values of w and z respectively, within the range of (-1,1). Then, use the command "plot(w,z)" to generate a 2D plot of w vs z. You can also customize the plot by adding labels, titles, and adjusting the axes using different Matlab commands.

3. Can I plot multiple w vs z plots in the same figure in Matlab?

Yes, you can plot multiple w vs z plots in the same figure in Matlab. To do this, use the "hold on" command before each "plot" command to ensure that the previous plot is not erased. You can also use the "legend" function to label each plot and differentiate them.

4. How can I change the color or style of my w vs z plot in Matlab?

To change the color or style of your w vs z plot in Matlab, you can use the "plot" command with additional arguments. For example, "plot(w,z,'r--')" will plot the w vs z data with a red dashed line. You can also use other colors and line styles such as 'b-', 'g:', etc. You can refer to the Matlab documentation for a full list of available options.

5. Is it possible to export my w vs z plot from Matlab?

Yes, it is possible to export your w vs z plot from Matlab. There are multiple ways to do this, such as saving the figure as an image file or copying the plot directly to your clipboard. You can also use the "print" command to export the plot to a specific file format, such as PDF or EPS. Additionally, you can use the "saveas" function to save the plot as a Matlab figure file for later use.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Calculus and Beyond Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
Back
Top