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 Comment

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

Sign in to comment.

Answers (0)

Tags

Asked:

on 29 Apr 2017

Commented:

on 29 Apr 2017

Community Treasure Hunt

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

Start Hunting!