calling multiple functions .m files
Afficher commentaires plus anciens
Hi there, i'm trying to simulate an earthquake shaking a structure. The earthquake signal generated by calling a separate function -and i've got this bit working, but i'm trying to call that signal into a function for the structure as: x'' = - earthquake - 2.eta.w.x' - w^2.x and then call that function using the ode45 solver. But i can't get this bit to work :( Would appreciate if someone can take a look at what i've done wrong (the stuff below where it says "CALLING FUNCTION" is the file I run for the simulation.
Thanks!
function dxdt = sdof(t,x)
t = [0:0.005:60];
eta = 0.05;
omega = 2*pi/0.15;
f = linspace(0,4,2048);
zeta = 0.3;
sigma = 0.3;
fn = 5;
T90 = 0.3;
eps = 2;
tn = 20;
[y,t] = kanai_tajimi_run(sigma,fn,zeta,f,T90,eps,tn);
earthquake = [y,t];
dxdt = [x(2);
- earthquake - 2*eta*omega*x(2) - omega^2*x(1)];
end
-----------------------
CALLING FUNCTION
_______________________
close all;clc;
[t,x] = ode45(@sdof,[0 60],[0; 0]);
plot(t,x)
title('Isolated structure response to MCE');
xlabel('Time (t)');
ylabel('Response (m, m/s)');
legend('Displacement (m)','Velocity (m/s)');
grid on;
1 commentaire
Walter Roberson
le 29 Avr 2017
[y,t] = kanai_tajimi_run(...)
Why are you overwriting the input parameter t ? That is, at the very least, confusing to the readers.
Réponses (0)
Catégories
En savoir plus sur Earthquake Engineering dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!