"Not enough input arguments, Error in my_ode_without_tld_1 (line 24) F = interp1(tdata,ydata)" why this error is showing?

1 view (last 30 days)
function dydt = my_ode_without_tld_1(t,y,tdata,ydata)
% tspan = i; %% Time span
%% Initial inputs
m1 = 8500; %% mass of the structure(kg)
k1 = 15; %% stiffness of the structure(N/m)
c1 = 5; %% damping of the structure(Ns/m)
A = 0.005; %% Amplitude of ground displacement(m)
f = 0.8671; %% Input frequencycy(Hz)
fs = 0.314465; %% Frequency of structure(Hz)
n = 1; %% Tuning ratio
%% define frequency
w1 = 2*pi*fs; %% frequency of structure(rad/sec)
%% define damping ratio of structure
r1 = 0.01;
%% define ground acceleration
ugdd = -A*(2*pi*f)^2*sin(2*pi*f*t);
F = interp1(tdata,ydata);
%% Equation to solve
dydt = [y(2) -ugdd-(2*r1*w1*y(2))-((w1)^2*y(1))+(F/m1)].';
clc;
clear all;
%% To run mass spring damper system
i = 0.1:0.1:30;
y = [0 0];
F = load('shear force.dat')';
%% Solve using ode45
[tsol,ysol] = ode45(@(t,y)my_ode_without_tld_1(t,y), i, y);
%% plotting
plot(tsol,ysol(:,1))
xlabel('time(sec)')
ylabel('displacement(m)')
grid on
title('Displacement response of structure')

Answers (1)

Torsten
Torsten on 14 May 2022
Edited: Torsten on 14 May 2022
If F has the same number of elements as i, the following should work:
i = 0.1:0.1:30;
y0 = [0 0];
F = load('shear force.dat')';
%% Solve using ode45
[tsol,ysol] = ode45(@(t,y)my_ode_without_tld_1(t,y,i,F), [0.1 30], y0);
%% plotting
plot(tsol,ysol(:,1))
xlabel('time(sec)')
ylabel('displacement(m)')
grid on
title('Displacement response of structure')
function dydt = my_ode_without_tld_1(t,y,tdata,ydata)
% tspan = i; %% Time span
%% Initial inputs
m1 = 8500; %% mass of the structure(kg)
k1 = 15; %% stiffness of the structure(N/m)
c1 = 5; %% damping of the structure(Ns/m)
A = 0.005; %% Amplitude of ground displacement(m)
f = 0.8671; %% Input frequencycy(Hz)
fs = 0.314465; %% Frequency of structure(Hz)
n = 1; %% Tuning ratio
%% define frequency
w1 = 2*pi*fs; %% frequency of structure(rad/sec)
%% define damping ratio of structure
r1 = 0.01;
%% define ground acceleration
ugdd = -A*(2*pi*f)^2*sin(2*pi*f*t);
F = interp1(tdata,ydata,t);
%% Equation to solve
dydt = [y(2) -ugdd-(2*r1*w1*y(2))-((w1)^2*y(1))+(F/m1)].';
end

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!