How to use 'trapz' command in a foor loop
Mostrar comentarios más antiguos
main file:
% Analysis of response spectra for given ground motion acceleration data
clear all
close all
clc
% Supershear & Subshear Earthquake Data
load Histories/IND.X0kY-1k.CXY.sema;% Ground-motion acceleration data
load Histories/IND.X0kY-2k.CXY.sema;% Ground-motion acceleration data
ground_acc(:,:,1) = IND_X0kY_1k_CXY;
ground_acc(:,:,2) = IND_X0kY_2k_CXY;
T_D = 8 ; % duration of earthquake in secs
dt = 0.002; % dt = sampling interval in seconds
xi = 0.02; % xi = ratio of critical damping
T_series_EQ = [0.002:dt:T_D]'; % Time column for EQ data
g =9.81 ; % accleration due to gravity in m/sec^2
% time period in vector form for response spectrum plot
Time_Period_Spectrum = [0.01:0.01:10];
for j=1:2
[PSA(:,:,j), PSV(:,:,j), SD(:,:,j), SA(:,:,j), SV(:,:,j), OUT(:,:,j),vel(:,:,j)] = responseSpectra(xi, Time_Period_Spectrum, ground_acc(:,:,j), dt);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Different Intensity Measure Calculation for EQ DATA %%%%%%%%%%%%%%%%
%%% Reference : Ground motion intensity measures for seismic probabilistic risk analysis
%% Peak Based Intensity Measure Calculation
for p=1:2
Peak_Ground_Velocity(p) = max(abs(vel(:,:,p)));
Peak_Ground_Accleration(p) = max(abs(ground_acc(:,:,p)));
%%% Pseudo-spectral accleration at fundamental period
T_f_structure = 1.42; % Fundamental Period of structure in sec
PSA_TF(p) = interp1 (Time_Period_Spectrum,PSA(:,:,p),T_f_structure);
%%% Spectral Intensity (related to kinetic energy stored in the structure During Earthquake)
S_v(:,p) = PSV(:,:,p)';
T = Time_Period_Spectrum';
Trange_SI = (T >= 0.1) & (T <= 2.5); %-period interval of Structures
I_H(p) = trapz(T(Trange_SI), S_v(:,p,(Trange_SI))); %Spectral_Intensity
end
Function file: given below
How to use Trapz command in case of loop for multiple eq data?
13 comentarios
Star Strider
el 9 de Mayo de 2021
That appears to me to be correct, and it is apparently not throwing errors.
How do you want to change it?
Sumit Saha
el 9 de Mayo de 2021
Star Strider
el 9 de Mayo de 2021
What problem?
Sumit Saha
el 9 de Mayo de 2021
Sumit Saha
el 9 de Mayo de 2021
‘Index exceeds matrix dimensions.’
That could be due either to the magnitude of ‘p’ or to ‘Trang_SI’. It is attempting to reference elements of ‘S_v’ that are greater than the dimensions of that array.
For example —
A = [1 2 3; 2 1 0];
B = A(3,4)
Sumit Saha
el 9 de Mayo de 2021
Sumit Saha
el 9 de Mayo de 2021
Star Strider
el 9 de Mayo de 2021
I understand what you want to do (at least as best as I can), however the issue of whether the loigical vector reference ‘Trang_SI’ or ‘p’ is throwing the dimension error is still not resolved (at least as far as I can understand this).
Prehaps knowing the dimensions of ‘S_v’ would help.
Sumit Saha
el 10 de Mayo de 2021
Sumit Saha
el 10 de Mayo de 2021
Star Strider
el 10 de Mayo de 2021
In the context of the code, what are ‘1.txt’ and ‘2.txt’?
They are vectors, however everything else seem to be matrices.
Sumit Saha
el 10 de Mayo de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Seismology en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!