Matlab - graphing multivariable functions

In summary, the individual is seeking assistance with graphing two equations, Z = (-1/4)x + y - 19 and Z = (-1/3)x + (2/3)y - 4, side by side in Matlab using the "subplot" function. They have tried using "help subplot" but are still having trouble understanding how to implement it. They are hoping someone can provide them with the code to graph these two equations and are grateful for any help.
  • #1
JoshHolloway
222
0
I am taking a vector calculus course and am having trouble figuring out how to graph things in Matlab to verify my answers.

Here is exactly what I want to do:
I want to graph side by side two different graphs simultaneously, so I can compare them.

I will give you the equations of the two planes I am attempting to graph side by side. If someone could write the code for me to graph these side by side, then I am sure I can play around with the code and figure out how to graph other functions.

I want to graph side by side the planes:
Z = (-1/4)x + y - 19
and
Z = (-1/3)x + (2/3)y - 4

Thanks in advance!
 
Last edited:
Physics news on Phys.org
  • #2
Anyone?
 
  • #3
Type "help subplot". This tells you how to plot multiple graphs in the same figure for convenient pictures
 
  • #4
I have tried that, but I still don't understand how to do it.

If someone could write the code to do what I am trying to do for those two equations I gave, then I would be EXTREMELY grateful.
 
  • #5
Is this enough? It will show you how to plot two vectors next to each other.

Code:
t = 0:0.01:10;
f1 = sin(t);
f2 = cos(t);subplot(1,2,1);
plot(f1);

subplot(1,2,2);
plot(f2);
 
  • #6
Awesome! Thanks!
 
  • #7
Try explot also.

ezplot((-1/4)x + y - 19) I think that should work. If not try
plot3d((-1/4)x + y - 19),x,-10,10,y,-10,10) x and y ranges are -10 to 10
 

1. How do I plot a multivariable function in Matlab?

To plot a multivariable function in Matlab, you can use the 'surf' function. This function creates a 3D surface plot of a function with two independent variables. The syntax is: surf(X, Y, Z) where X and Y are matrices of the same size that define the coordinates of the points in the grid, and Z is a matrix of the same size that contains the corresponding function values.

2. How do I label the axes and add a title to my graph in Matlab?

To label the axes and add a title to your graph in Matlab, you can use the 'xlabel', 'ylabel', and 'title' functions. The syntax is: xlabel('x-axis label'), ylabel('y-axis label'), and title('graph title'). You can also customize the font size, style, and other properties of these labels and title using additional input arguments.

3. Can I change the color or style of the graph lines in Matlab?

Yes, you can change the color or style of the graph lines in Matlab by using the 'color' and 'linestyle' input arguments in the 'plot' function. For example, you can use 'plot(x, y, 'r--')' to plot a red dashed line. You can also use the 'plot3' function to create 3D line plots with customized colors and styles.

4. How do I add a legend to my multivariable function graph in Matlab?

To add a legend to your multivariable function graph in Matlab, you can use the 'legend' function. The syntax is: legend('legend1', 'legend2', ...) where each string in the parentheses corresponds to the label for each plot in your graph. You can also specify the location and format of the legend using additional input arguments.

5. Can I create contour plots for multivariable functions in Matlab?

Yes, you can create contour plots for multivariable functions in Matlab using the 'contour' or 'contourf' functions. These functions create 2D contour plots of a function with two independent variables. The 'contour' function creates contour lines while the 'contourf' function creates filled contour plots. The syntax is: contour(X, Y, Z) or contourf(X, Y, Z) where X and Y are matrices defining the coordinates of the grid and Z is a matrix containing the function values. You can also customize the number and spacing of the contour lines using additional input arguments.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
133
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
32
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
688
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Back
Top