Plot the function y(x, ) from Exercise 11 for 5 = 0.3, 0.5, and 0.8. Create one figure with four subplots and plot y for three different values of 5 in three subplots and fourth subplot should have multiple plots of y for all the values of 5.
clc;clear all;format compact
x=input('Enter range of x values for which plot is to be created: '); %Asks user to enter x
zeta=[0.3 0.5 0.8]; %Values of zeta
%Computes y(x) for each zeta
y1=1-((1/sqrt(1-zeta(1)^2)))*exp(-zeta(1).*x).*sin(sqrt(1-zeta(1)^2).*x+acos(zeta(1)));
y2=1-((1/sqrt(1-zeta(2)^2)))*exp(-zeta(2).*x).*sin(sqrt(1-zeta(2)^2).*x+acos(zeta(2)));
y3=1-((1/sqrt(1-zeta(3)^2)))*exp(-zeta(3).*x).*sin(sqrt(1-zeta(3)^2).*x+acos(zeta(3)));
%Creates 4 subplots as asked.
subplot(2,2,1)
plot(x,y1,'-k','LineWidth',2);xlabel('x in radians');ylabel('y(x)');title('\zeta=0.3');
subplot(2,2,2)
plot(x,y2,'-r','LineWidth',2);xlabel('x in radians');ylabel('y(x)');title('\zeta=0.5');
subplot(2,2,3)
plot(x,y3,'-b','LineWidth',2);xlabel('x in radians');ylabel('y(x)');title('\zeta=0.8');
subplot(2,2,4)
plot(x,y1,x,y2,x,y3,'LineWidth',2);xlabel('x in radians');ylabel('y(x)');legend('\zeta=0.3','\zeta=0.5','\zeta=0.8');
Step by step
Solved in 2 steps with 2 images