calling multiple functions .m files

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 个评论

[y,t] = kanai_tajimi_run(...)
Why are you overwriting the input parameter t ? That is, at the very least, confusing to the readers.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Earthquake Engineering 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by