Help with for loop array plotting
3 ビュー (過去 30 日間)
古いコメントを表示
I cannot figure out why I have no output for the displacement response graphs in my code. Help!
clear all
close all
clc
data=xlsread('NS record 1940 El Centro Earthquake.xlsx');
t=data(:,1)';
ac=data(:,2)';
acc=ac*9.8;
figure(1)
plot(t,ac)
title('Ground Acceleration')
% zeta=2/100;
% T0=1;
% omega=2*pi/T0; %omega=2*pi/T0
% omegad=omega*sqrt(1-zeta^2);
% k=10;
% m=k/(omega^2);
m=1;
% amplitude=0.5;
% tmax=5;
% Tp=0.5;
dtau=0.02;
Tnset=[0.5 1 2 2 2 2];
zetaset=[0.02 0.02 0.02 0 0.02 0.05];
omegaset=2*pi./Tnset; %omega=2*pi/T0
omegadset=omegaset.*sqrt(1-zetaset.^2);
for k=1:length(Tnset)
for j=1:length(t)
if j<=3
Ae(j)=(t(j)/3)*...
(acc(j)*(-zetaset(k)*omegaset(k)*t(j+3))+...
4*acc(j)*exp(-zetaset(k)*omegaset(k)*t(j+2))*cos(omegadset(k)*t(j))+...
2*acc(j)*exp(-zetaset(k)*omegaset(k)*t(j+1))*cos(omegadset(k)*t(j+1))+...
4*acc(j+2)*exp(-zetaset(k)*omegaset(k)*t(j))*cos(omegadset(k)*t(j+2))+...
acc(j+3)*cos(omegadset(k)*t(j+3)));
Be(j)=(dtau/3)*...
(acc(j)*(-zetaset(k)*omegaset(k)*t(j+3))+...
4*acc(j)*exp(-zetaset(k)*omegaset(k)*t(j+2))*sin(omegadset(k)*t(j))+...
2*acc(j)*exp(-zetaset(k)*omegaset(k)*t(j+1))*sin(omegadset(k)*t(j+1))+...
4*acc(j+2)*exp(-zetaset(k)*omegaset(k)*t(j))*sin(omegadset(k)*t(j+2))+...
acc(j+3)*cos(omegadset(k)*t(j+3)));
else
Ae(j)=(t(j-3)/3)*...
(acc(j-3)*(-zetaset(k)*omegaset(k)*t(j))+...
4*acc(j-3)*exp(-zetaset(k)*omegaset(k)*t(j-1))*cos(omegadset(k)*t(j-3))+...
2*acc(j-3)*exp(-zetaset(k)*omegaset(k)*t(j-3))*cos(omegadset(k)*t(j-2))+...
4*acc(j-1)*exp(-zetaset(k)*omegaset(k)*t(j-3))*cos(omegadset(k)*t(j-1))+...
acc(j)*cos(omegadset(k)*t(j)));
Be(j)=(t(j-3)/3)*...
(acc(j-3)*(-zetaset(k)*omegaset(k)*t(j))+...
4*acc(j-3)*exp(-zetaset(k)*omegaset(k)*t(j-1))*sin(omegadset(k)*t(j-3))+...
2*acc(j-3)*exp(-zetaset(k)*omegaset(k)*t(j-3))*sin(omegadset(k)*t(j-2))+...
4*acc(j-1)*exp(-zetaset(k)*omegaset(k)*t(j-3))*sin(omegadset(k)*t(j-1))+...
acc(j)*cos(omegadset(k)*t(j)));
end
un(j)=(1/(m*omegadset(k)))*(Ae(j)*sin(omegadset(k)*t(j))-Be(j)*cos(omegadset(k)*t(j)));
end
figure('Name','Displacement Plot','NumberTitle','off');
plot(t,un(k))
% figure('Name','Plots','NumberTitle','off');
% %title('Tn = ',Tnset(k),' sec, zeta = ',zetaset(k))
end
% tiledlayout(3,2);
% nexttile
% for k=1:length(Tnset)
% nexttile
% end
2 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!