k=input(' Enter the value of the spring stiffness k: ');
c=input(' Enter the value of the damping coefficient c: ');
m=input(' Enter the value of the mass: ');
t0=input(' Enter the initial time t0: ');
tf=input(' Enter the final time tf: ');
x0=input(' Enter the initial displacement x0: ');
v0=input(' Enter the initial velocity v0: ');
x=[x0 v0];
t=[t0 tf];
cr=2*sqrt(k*m);
z=c/cr;
disp(['the result ' num2str(z)]);
if z<1
disp('It is an Under-Damped Response')
[t1,x1] = Pro_1(k,c,m,t,x);
plot(t1,x1(:,1),t,x1(:,2),'Linewidth',2.5)
end
The Function is :
function [t1,x1]=Pro_1(k,c,m,t,x)
[t1,x1] = ode45(rif,t,x);
function xdot = rif(t1,x1)
xdot= zeros(2,1);
xdot(1)=x1(2);
xdot(2)=(-k/m)*x1(1)-(c/m)*x1(2);
end
end
Can anyone help me please ???
1
Expert's answer
2014-01-09T11:32:06-0500
Dear visitor, Unfortunately, the statement of your question is a bit confusing. What do you need to be done? Please, give us the details so we could help you.
Comments
Leave a comment