MATLAB: Help in graph plotting

3d plotscontourfunctionshomeworkmesh

Given a function ?(?,?)=10sin ?.where ?=√?2+?2.
Create a figure containing of twodifferent three-dimensional subplots (i.e. mesh and contour plots) of the function ?(?,?)where both ? and ? are ranging from -10 to 10. For both subplots, label the axes and showthe color bar to identify the variation of z.
x=linspace(-10,10);
y=linspace(-10,10);
t=sqrt(x.^(2)+y.^(2));
Z = 10*sin(sqrt(x.^(2)+y.^(2)));
%graphing
figure(1)
mesh(Z);
xlabel('x')
ylabel('y')
zlabel('10 sin(t)')
figure(2)
contour3(Z);
xlabel('x')
ylabel('y')
zlabel('10 sin(t)')
What went wrong actually?
No graph were plotted when run

Best Answer

x=linspace(-10,10);
y=linspace(-10,10) .'; %CHANGED
t=sqrt(x.^(2)+y.^(2));
Z = 10*sin(sqrt(x.^(2)+y.^(2)));
%graphing
figure(1)
mesh(Z);
xlabel('x')
ylabel('y')
zlabel('10 sin(t)')
figure(2)
contour3(Z);
xlabel('x')
ylabel('y')
zlabel('10 sin(t)')