Please type the Matlab commands for this 2.5 The following equation can be used
ID: 3196263 • Letter: P
Question
Please type the Matlab commands for this
2.5 The following equation can be used to compute values of y as a function of 1: 1. = be-a-sin(b.r )(0.01 2x4-0. l 5x3 0.075x2 + 2.5x ) where a and b are parameters. Write the equation for imple- mentation with MATLAB. where a = 2, b = 5, and x is a vector holding values from 0 to /2 in increments of Ar = /40. Employ the minimum number of periods (ie dot notation) so that your formulation yields a vector for y In addition, compute the vector- where each element holds the square of each element of y. Combine x, y, and into a matrix w, where each column holds one of the vari- ables, and display w using the short g format. In addition. generate a labeled plot of y and versus x. Include a legend on the plot (use help to understand how to do this). For y. use a 1.5-point, dashdotted red line with 14-point, red- edged, white-faced pentagram-shaped markers. For z, use a standard-sized (i.e., default) solid blue line with standard- sized, blue-edged, green-faced square markers.Explanation / Answer
clc
close all
a = 2;
b = 5;
x = 0:pi/40:pi/2;
y = b*exp(-a*x).*sin(b*x).*(0.012*x.^4 - 0.15*x.^3 + 0.075*x.^2 + 2.5*x);
z = y.^2;
w = [x;y;z]';
figure;
plot(x,y, 'r', x,z,'b')
xlabel('Pi')
ylabel('Y & Z')