How to input a half sine pulse force with varying loads for different time variables?

11 views (last 30 days)
I am working on replicating a Half Sine Pulse Force Function from Dynamics of Structures (4th edition by Chopra). The loading function, p(t)=10*sin(pi*t/0.6). It is a piecewise function in that the load is present from 0 to 0.6 seconds, and is zero therafter. I have tried creating a "for" if-else loop but with little success.
Additionally, the problem is Example 5.2 in Dynamics of Structures, which includes solving through central difference method.
My m file reads as such:
%VARIABLES delt=0.1; %time step m=0.2533; k=10; zeta=0; t=[0:delt:2]'; td=0.6; T=1;
wn=sqrt(k/m); c=2*zeta*wn*m;
P=10*sin(pi*t/0.6); %input loading n=size(P,1); %length of load vector
for t=0:n+2 if t<0.6 P=10*sin(pi*t/0.6) else P=0 end end
%define initial values F(1)=0; F(2)=0; d(2)=0; v(2)=0; a(2)=1/m*(P(2)-c*v(2)-k*d(2)); d(1)=d(2)-delt*v(2)+delt^2/2*a(2);
%coefficient of d(i+1) A=m/delt^2-c/(2*delt); B=k-2*m/(delt^2); C=m/delt^2+c/(2*delt);
%iteration
for i=3:n+2 TT(i)=t(i-2); F(i)=P(i-2); d(i)=2*delt*v(i-1)+d(i-2); d(i+1)=1/C*(F(i)-A*d(i-1)-B*d(i)); v(i)=(d(i+1)-d(i-1))/(2*delt); a(i)=(d(i+1)-2*d(i)+d(i-1))/delt^2; v(i+1)=v(i); %virtual a(i+1)=a(i); %virtual TT(i+1)=TT(i); %virtual F(i+1)=F(i); %virtual end
result=[TT' F' d' v' a']; xlswrite('cdm result.xls',result)
figure (1) plot (t,P) xlabel('Time (seconds)') ylabel ('Load (kip/in)') title ('Input loading') grid on

Answers (1)

sam0037
sam0037 on 13 Apr 2016
Hi,
You can define your load in the following way:
delt = 0.1;
t = [0:delt:2]';
P = 10*sin(pi*t/0.6); %input loading
plot(t,P,'-r*');
hold on;
P(t>0.6)=0; % values where t>0.6 will be assigned to zero
plot(t,P,'-co');
legend('full sine load','desired load')
Modify the above as per your requirement. Click here to know more about logical indexing.

Categories

Find more on Programming 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!