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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started