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

1 次查看(过去 30 天)
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')

回答(1 个)

Torsten
Torsten 2022-5-14
编辑:Torsten 2022-5-14
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

类别

Help CenterFile Exchange 中查找有关 Partial Differential Equation Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by