Using Matlab Problem 1: 4. Create a vector of x values from 0 to 20pi, with an i
ID: 3764388 • Letter: U
Question
Using Matlab Problem 1: 4. Create a vector of x values from 0 to 20pi, with an increment of pi/100. y = x sin(x) and z = x cos(x) (a) Create a 3D line plot of x, y and z. Add title and labels to every graph. [Hint: slide #15] (b) Create a mesh, use A = [x; y; z]; mesh(A);
problem 2: 5. Use meshgrid() to create a grid of x and y from -10 to 10 with an increment 0.5. Then calculate matrix Z = x2+y2. Use subplot command to divide the figure window to 4 divisions. Create plot3, surf, mesh and contour3 (with 20 levels) in those 4 divisions. Add title and labels to every graph. The surface plot should be flat and blue color, wouldn’t show any mesh, as shown below.
Explanation / Answer
1:4)
a)
X=0:pi/100:20*pi;
Y=X.*sin(X);
Z=X.*cos(X);
scatter3(X,Y,Z);
b)
X=0:pi/100:20*pi;
Y=X.*sin(X);
Z=X.*cos(X);
A = [X; Y; Z];
mesh(A);
2:5)
[X,Y] = meshgrid(-10:0.5:10, -10:0.5:10);
Z=X^2+Y^2;
figure
subplot(2,2,1)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('plot3')
plot3(X,Y,Z)
subplot(2,2,2)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('surf')
surf(X,Y,Z)
subplot(2,2,3)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('mesh')
mesh(X,Y,Z)
subplot(2,2,4)
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('contour3')
contour3(X,Y,Z)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.