In: Computer Science
The following equation can be used to compute values of y as a function of x: ? = ?? −??sin(??)(0.012? 4 − 0.15? 3 + 0.075? 2 + 2.5?) where a and b are parameters. Write a Matlab script file (m file) with the following steps: Step 1: Define scalars a = 2, b = 5. Step 2: Define vector x holding values from 0 to π/2 in increments of Δx = π/40. Step 3: generate the vector y using element-wise product (dot product). Step 4. Compute the vector z = y 2 where each element holds the square of each element of y. Step 5: Combine x, y, and z into a matrix w, where each column holds one of the variables, and display w using the short g format. Step 6: Generate plots of y and z versus x using dashed lines. Step 7: Include legends for each plot (for y vs. x plot, use “y” as legend; for z vs. x plot, use “z” as legend).
`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
clc
clear all
close all
b=5;
a=2;
x=transpose(0:pi/40:pi/2);
y=sin(b*x).*(0.012*x.^4-0.15*x.^3+0.075*x.^2+2.5*x).*(b*exp(-a*x));
z=y.^2;
format short g;
w=[x y z];
disp(w)
plot(x,y,'--',x,z,'--');
xlabel('X');
ylabel('Amplitude');
title('Plot of y and z');
legend('y','z');
Kindly revert for any queries
Thanks.