step plot function in matlab

Saturday, May 3, 2014

I am trying to plot step responses in matlab and cannot figure it out for anything, I have graphed a Bode plot for 3 different K values and now must do the same for step, but am trying to no avail, can anyone provide any suggestions?


Here is the differential equation in the time domain:


d^2y(t)/dt + (v/m)dy(t)/dt + (k/m)y(t) = (k/m)x(t)


Here is the code for my Bode plot and my attempted but failed step:



w=logspace(-2,2,100);
b=[1];
a=[1 2^(.5) 1];
H1=freqs(b,a,w);
b=[.09];
a=[1 (2^.5)*(.09^.5) .09];
H2=freqs(b,a,w);
b=[4];
a=[1 2*(2^.5) 4];
H3=freqs(b,a,w);
loglog(H1,w,'r-')
hold on
loglog(H2,w,'g*')
loglog(H3,w,'bo')
xlabel('Omega')
ylabel('Frequency Response')
title('Bode plot of various K values')
legend('H1, K=1','H2, K=.09','H3, K=4')
hold off


x=linspace(0,30);
eqn1=' D2y + (2^.5)*Dy + (1)*y=(1)*x';
eqn2=' D2y + (2^.5*(.09^.5))*Dy + (.09)*y=(.09)*x';
eqn3=' D2y + (2^.5*(2))*Dy + (2)*y=(2)*x';

y1=dsolve(eqn1);
y2=dsolve(eqn2);
y3=dsolve(eqn3);

z1 = eval(vectorize(y1))
z2 = eval(vectorize(y2))
z3 = eval(vectorize(y3))






http://ift.tt/1icrZlP