Develop a MATLAB script to generate a 5 panel vertical plot to illustrate how a function changes as the parameters change. On each plot, display the simple sine wave, y(t) = sin(2πt), as a red line. Then, add the following functions to each of the 5-panels as black lines:

Respuesta :

The question is incomplete. Complete question along with Matlab code, explanation, and output results are given below.

Complete Question:

Develop a MATLAB script to generate a 5 panel vertical plot to illustrate how a function changes as the parameters change. On each plot, display the simple sine wave, y(t) = sin(2πt), as a red line. Then, add the following functions to each of the 5-panels as black lines:

y(t) = sin(2πt)  sine function

y1(t)=1+sin(2πt) effect of mean

y2(t)=2sin(2πt) effect of amplitude

y3(t)=sin(4πt) effect of frequency

y4(t)=sin(2πt) - π/4) effect of phase shift

y5(t)=cos(2πt) - π/2) relationship between sine and cosine

Step-by-step explanation:

We are required to show different sinusoidal plots to illustrate the effects of changing mean, amplitude, frequency, phase shift, and relationship of sine and cosine wave.

t=[0:0.01:2*pi] % time vector from 0 to 2pi

y=sin(2*pi*t); % the original sine function  

% effect of mean

y1=1+sin(2*pi*t);  

subplot(5,1,1) % 5 rows, 1 column and last for position

plot(t,y,'k',t,y1,'r')  % this function plots y and y1 with respect to time vector t

% 'k' for black color and 'r' for red color

grid on  

xlabel('time (t)') % x-axis is for time

ylabel('y1(t)')  % y-axis is for function value y(t)

title('effect of mean') % title of the plot

ylim([-3 3]) % limit of y-axis

xlim([0 6]) % limit of x-axis

% effect of amplitude

y2=2*sin(2*pi*t);

subplot(5,1,2)  

plot(t,y,'k',t,y2,'r')  

grid on  

xlabel('time (t)')  

ylabel('y2(t)')  

title('effect of amplitude')  

ylim([-3 3])  

xlim([0 6])  

% effect of frequency

y3=sin(4*pi*t);  

subplot(5,1,3)  

plot(t,y,'k',t,y3,'r')  

grid on  

xlabel('time (t)')  

ylabel('y3(t)')  

title('effect of frequency')  

ylim([-3 3])  

xlim([0 6])  

% effect of phase shift

y4=sin((2*pi*t)-pi/4);  

subplot(5,1,4)  

plot(t,y,'k',t,y4,'r')

grid on  

xlabel('time (t)')  

ylabel('y4(t)')  

title('effect of phase shift')  

ylim([-3 3])  

xlim([0 6])  

% relationship between sine & cosine

y5=cos((2*pi*t)-pi/2);  

subplot(5,1,5)  

plot(t,y,'k',t,y5,'r')  

grid on  

xlabel('time (t)')  

ylabel('y5(t)')  

title('relationship between sine & cosine')  

ylim([-3 3])  

xlim([0 6])  

Output Results:

The first plot shows that sine wave gets shifted to upper side with respect to the original sine wave.

The second plot shows that the amplitude of the sine wave is increased with respect to the original sine wave.

The third plot shows that the frequency of the sine wave is increased. The number of cycles are increased with respect to the original sine wave.

The fourth plot shows there is a phase shift between two waves. The modified sine wave lags the original sine wave by π/4  

The fifth plot shows the relationship between sine and cosine wave.

As we know sin(2πt)=cos(2πt - π/2)

Therefore, both waves are superimposed on each other since they are equal.

Ver imagen nafeesahmed