Use Matlab to plot x(t) for damped system

vendredi 31 janvier 2014

1. The problem statement, all variables and given/known data

Plot x(t) for a damped system of natural frequency w_n= 2 rad/s and initial conditions x_0= 1 mm and v_0 = o mm/s, for the following values of the damping ratio: z= 0.01, 0.2, 0.6, 0.1, 0.4 and 0.8

2. Relevant equations







3. The attempt at a solution



I began by defining the values of my constants. I realize that z is not a constant per se but I'm not particularly knowledgeable about matlab



w_n=2; %rad/s

x_0=1; %mm

v_0=0; %mm/s

z= 0.01; %this value varies, thereby changing the response of the plot



Next I defined the time interval as well as some intermediate variables and the solution to a damped system.



t=[0:0.1:2*3.41];

w_d=w_n*sqrt(1-z^2);

x=x_0*exp(z*w_n*t_i)*sin(w_d*t_i);



With the above code I'm told:



Error using *

Inner matrix dimensions must agree.



I spoke to my professor about this and he explained that my exp and sin portions of x were 1x63 and 1x63 matrices, which doesn't work out. I've got the following lines of code which he gave me, but I'm still confused.



x=zeros(63,1);

for i=1:63

x(i)=x_0*exp(z*w_n*t(i))*sin(w_d*t(i));

end

plot(t,x)



Trying to use this code as it is just repeats:



Error using *

Inner matrix dimensions must agree.



Any help would be greatly appreciated





0 commentaires:

Enregistrer un commentaire