this shows the response u(t) of a given ground acceleration. I need to generate this code for a given 'time vector' instead of a discrete value of Tn. Thank you for helping
How to generate this function to a time vector instead of discrete value of Tn
1 view (last 30 days)
Show older comments
function[u]=centraldiff(Tn,zeta,v1,u1,acc,dt)
%zeta is the damping ration
%Tn is the natural period
%acc is the ground acceleration
%dt is the time step
%u1=0; % displacement at point t=0 of SDOF
%v1=0; % velocity at point t=0 of SDOF
wn=2*pi/Tn;
an(1)=acc(1)-(2*zeta*wn)*v1-(wn^2)*u1;
up=u1-dt*v1+dt^2*an(1)/2;
u(2)=-acc(1)/(1/dt^2+wn*zeta/dt)+((-1/dt^2+wn*zeta/dt)/(1/dt^2+wn*zeta/dt))*up+((-wn^2+2/dt^2)/(1/dt^2+wn*zeta/dt))*u1;
u(3)=-acc(2)/(1/dt^2+wn*zeta/dt)+((-1/dt^2+wn*zeta/dt)/(1/dt^2+wn*zeta/dt))*u1+((-wn^2+2/dt^2)/(1/dt^2+wn*zeta/dt))*u(2);
for m=3:12000;
u(m+1)=-acc(m)/(1/dt^2+wn*zeta/dt)+((-1/dt^2+wn*zeta/dt)/(1/dt^2+wn*zeta/dt))*u(m-1)+((-wn^2+2/dt^2)/(1/dt^2+wn*zeta/dt))*u(m);
end
T=0:dt:60;
plot(T,u,'k');
xlabel('Time (t) in seconds')
ylabel('Response U(t) in units')
title('Response U(t)/Tn=2 , zeta=0.05')
end
Answers (0)
See Also
Categories
Find more on Assembly in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!