1 Matlab Graphics Introduction to Matlab 7 Omed Ghareb Abdullah Sulaimani University Sulaimani University College of Sciences College of Sciences Physics Department Physics Department 1 3D graph In this section we will focus on the basic MATLAB i t ti f l tti 3 D h MATLAB instructions for plotting a 3-D graph and controlling its appearance. Ref: help graph3d 2
Lecture (7): Matlab Graphics - Sulaimani University - College of Science - Physics Department
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Matlab Graphics
Introduction to Matlab 7
Omed Ghareb AbdullahSulaimani UniversitySulaimani UniversityCollege of SciencesCollege of SciencesPhysics DepartmentPhysics Department
1
3D graphIn this section we will focus on the basic MATLAB i t ti f l tti 3 D h MATLAB instructions for plotting a 3-D graph and controlling its appearance.Ref: help graph3d
2
2
meshgrid• meshgrid generates x and y grid coordinates of a
rectangular mesh.g• Example:
x=linspace(-5,5,30);
y=linspace(-2,2,20);
[X,Y]=meshgrid(x,y);
ill d t 5 b 6 t i i d iwill produce two 5 by 6 matrices xi and yiwhich contain the x and y coords, respectively, of a 5 by 6
rectangular grid. xi and yi can now be used as templates when interpolating randomly
scattered data into a uniform grid for contour and surface plotting routines as shown by the next slide.
The peaks(100) function creates a 100x100 array of values. Since this is a plot of a single variable, we get 100 different line plots
36
19
The peaks( ) FunctionWe'll use peaks( ) to create a z=f(x,y) function that is interesting and shows off the 3‐D plottingsee help peaks for more info on this functionsee help peaks for more info on this function
[x,y,z]=peaks(30);
mesh(x,y,z)
xlabel('x-axis')( )
ylabel('y-axis')
zlabel('z-axis')
37
The peaks( ) FunctionWe'll use peaks( ) to create a z=f(x,y) function that is interesting and shows off the 3‐D plottingsee help peaks for more info on this function