Using MATLAB, Obtain the plot of z = sinr where r = sqrt (x2 +y2) over the domain (−20<x,y<20). In order to define your domain, you may start with xd=-20:40/99:20; yd = xd; [x,y] = meshgrid(xd,yd);. Then you might first compute r= sqrt(x.^2+y.^2); z= sin(r)./r;. Following this, issue the command plot3(x,y,z,’k’) to get the 3-D plot of this surface. Here ’k’ makes it black. Next instead of plot3(x,y,z,’k’) you can try mesh(x,y,z); colormap([1,0,0]) to get a red mesh plot. You may vary the colormap to ([0,1,0]) for green and ([0,0,1]) for blue and mix these three colors as you like, say ([0.3,.4,0.2]) and see a different color.
please respond with MATLAB code.
code :
output :
output2 :
when mesh(x,y,z) is used instead of plot3 you get this output.
raw_code :
xd = -20:40/99:20; %in given interval
yd = xd;
[x,y] = meshgrid(xd,yd);
r = sqrt(x.^2+y.^2); %computing r
z=sin(r)./r; %computing z
plot3(x,y,z,'k') %plotitng in 3D
%mesh(x,y,z);
%colormap([1,0,0])
**do comment for queries and rate me up***
Get Answers For Free
Most questions answered within 1 hours.