"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')
댓글 수: 0
답변 (1개)
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 Center 및 File Exchange에서 Partial Differential Equation Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!