Question: Please add comments to this Matlab code: a) n=1; m=1; stepSize=0.01; for a= -10:stepSize:10 for b= -10:stepSize:10 y(m, n)=funPlot(a,b); x1(m,n)=a; x2(m,n)=b; n=n+1; end m=m+1; n=1;

Please add comments to this Matlab code:

a)

n=1;

m=1;

stepSize=0.01;

for a= -10:stepSize:10

for b= -10:stepSize:10

y(m, n)=funPlot(a,b);

x1(m,n)=a;

x2(m,n)=b;

n=n+1;

end

m=m+1;

n=1;

end

figure

mesh(x1, x2, y)

xlabel('a')

ylabel('b')

zlabel('y')

function y = funPlot(a,b)

if ((abs(a)>abs(b)) || (abs(a)

y=a*a+b*b;

elseif abs(a)==abs(b)

y=0;

end

end

b)

clc

clear all

close all

n=1;

for k=-10:0.01:10

x(n) = k;

if((x(n)<=-1) || ((x(n)>=0) && (x(n)<1)) || (x(n)>=5))

y(n)=0;

elseif ((x(n)>-1) && (x(n)<0))

y(n)=-2*x(n);

elseif (x(n)>=1) && (x(n)<2)

y(n)=-2+2*x(n);

elseif (x(n)>=2) && (x(n)<4)

y(n)=2;

else y(n)=-6+2*x(n);

end

n=n+1;

end

figure

plot(x,y)

axis([-10 10 -0.1 6])

grid on

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!