![Matlab plot](https://case.faraton.info/33.png)
The function that we were asked to plot is the following: 1 = x^(2)/9 - y^(2)/4 Furthermore it doesn't look anything like the example we were given for reference.
MATLAB PLOT CODE
My Matlab is a little rusty, and I don't think that I quite got the code right. We have a new assignment which is to generate a graph of a given function (in Matlab), save it and then recall it in LaTeX code as though we're making a publication. Here's another way.In addition to my R programming course, I am also taking an intro to LaTeX course. Hold off Changing Colors of Surfaces, Example 3 Here's another way, using RGB codes for colors: xd=linspace(-2,2,40) Ĭ1=(1/255)* % establishing color of first plane: Loyola GreenĬ2=(1/255)* % establishing color of second plane: Loyola GoldĬ3=(1/255)* % establishing color of third plane: Loyla Gray % first plane Hold off Changing Colors of Surfaces, Example 2 There are several ways to do this, many of them get really fancy. Hold off Changing Colors of Surfaces, Example 1 =meshgrid(linspace(-2*pi,2*pi)) Īs in the 2D case, just add points using plot3 command and specifying the marker type.
![matlab plot matlab plot](https://it.mathworks.com/help/examples/matlab/win64/Creating3DPlotsExample_02.png)
You can plot surfaces and vector functions on the same figure using the hold on command. Hold off Combining vector functions and surfaces Same graph as above, but adjusting the view and the number of points in the meshgrid u=linspace(-5,5,41) Hold off Adjusting view and the meshgrid size Z2=0*x + exp(1) % the 0*x + exp(1) makes sure the output for z2 is the same size % as x and y, but only has the value of e in each component. thus, you can do the following: u=linspace(-5,5,81) If you were to just define \( z = e \), it would only assign z to be one number, but we need the number e assigned at the z-value for each (x,y) in the domain.
MATLAB PLOT HOW TO
This example shows how to graph a horizontal plane. Title( '3D Example with different domains')
![matlab plot matlab plot](https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/3832/versions/1/screenshot.png)
The number of points used for x and y MUST BE EQUAL thus, 51 for both of them in this example CAREFUL! this "51" number may need to be adjusted to make a smooth, nice graph and not hang the computer u=linspace(0.75,1.25,51) The command linspace(a,b,N) gives N points between a and b so linespace(0.75,1.25,81) gives 51 points between 0.75 and 1.25. This example demonstrates a way to have different x and y ranges. Hold off %%%%% DON'T FORGET TO HOLD OFF!! %%%%% Another 3D Surface Example Title( '3D Plot Example of multiple graphs') Again, you may need to adjust how many points are used to make the graph not too jagged (if number too low) or not hang the computer (number too high). Notice in this example we used a different way to get the domain for x,y using linspace as opposed to the above example. This example demonstrates how to plot more than one graph on the same figure. The ZLIM command changes the range of the z-axis shown (you can likewise use XLIM and/or YLIM). We could have equally used the following command mesh(x,y,z) % check out the difference in the graphs! Adding axes labels, titlesĬAREFUL! One of mesh and surf may be more appropriate for different graphsįollowing labels the axes and creates a title mesh(x,y,z) You don't want too few points in the "grid" or it will appear jagged, but too many and the computer will slow down or even hang! xd=linspace(-1,1) The meshgrid command is vital for 3D surfaces!ĭefining the domain here is even trickier than for 2D. This example shows one way to plot 3D surfaces. The main commands are mesh(x,y,z) and surf(z,y,z)
![matlab plot matlab plot](http://i.stack.imgur.com/zoRp9.jpg)
Calculate z for the surface, using component-wise computations.Create a "grid" in the xy-plane for the domain using the command meshgrid.Establish the domain by creating vectors for x and y (using linspace, etc.).
![matlab plot matlab plot](https://1.bp.blogspot.com/-rAMD0hAI84w/VwT29QlvEeI/AAAAAAAALPI/zIlLgGOfJ4odMiUHoMCOZoxoSsmmNjKeQ/s1600/111.png)
It is up to you to experiment and look up these commands to better understand them. I do not explain every command or show everything. This page will not show all of them it will show the way that is the most customizable and can be easily extended to more complicated settings (like parametric equations, 3D, etc.) This is also a learn-by-example page. There are several ways to produce graphs of functions. There are many other examples on the H-drive! You may want to have the following commands at the top of your script files to "start fresh" clc % clears the command windowįormat % resets the format to the default format
![Matlab plot](https://case.faraton.info/33.png)