Question: Look up linspace. In your m-file, use linspace to define a row vector named xxthat has 400 equally spaced points that vary in value from

Look up linspace. In your m-file, use linspace to define a row vector named xxthat has 400 equally spaced points that vary in value from -5 to 5. Now calculate a function fx1. fx1=sin(3*pi*xx).*exp(-xx.^2);

This defines fx1 in terms of xx., using array multiplication. Now define another function, fx2, thats the same as fx1 except that the magnitude of fx2 cannot exceed 0.5.

fx2=zeros(size(xx));

for ii=1:length(xx)

if abs(fx1(ii))<0.5

fx2(ii)=fx1(ii);

elseif fx1(ii)>0.5

fx2(ii)=0.5;

elseif fx1(ii)<0.5

fx2(ii)=-0.5;

end

end

Look up the command while, and use a while loop to find the first value of xx where fx1 is greater than fx2. Include this in your m-file and put the answer in your write-up.

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!