Help with for loop array plotting

조회 수: 2 (최근 30일)
Laura Bell
Laura Bell 2021년 3월 31일
댓글: Laura Bell 2021년 3월 31일
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
KSSV
KSSV 2021년 3월 31일
What you have done in for loop can be done without it.....
Laura Bell
Laura Bell 2021년 3월 31일
I'm not sure what you mean..

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by