ODE 45 not working - not enough input arguments
이전 댓글 표시
Hi, I'm having an issue with the code shown below. The main problem is with the ode45 solver and the number of variables involved:
function mdot=sim1(t,p,q)
%
Vm=1;
I1=800;
I2=3200;
R1=4000;
R2=800;
C1=1e-5;
C2=5e-6;
M=0.1;
rp=.02;
Ft=0;
A=3.14159*(rp^2);% area of the piston pushing into hydraulic system
n=Vm*A; %relation between TF from V to Q
I=M;
%
p2dot=(Ft/(1+n^2*(I1/I)))+((R1*n^2*(1/I)*p(2))/(1+n^2*(I1/I)))+((n*(1/C1)*q(8))/(1+n^2*(I1/I)));
q8dot=(n*(1/I)*p(2))-((1/I(2))*p(10));
p10dot=((1/C1)*q(8))-(R2*(1/I1)*p(10))-((1/C2)*q(12));
q12dot=(1/I2)*p(10);
%
mdot=[p2dot;q8dot;p10dot;q12dot];
The function is coupled with this code:
clear all
clc
%
tspan=[0 100]; % Time range, [s]
x0=[0;0;0;0]; % Initial momentum and displacement values
%
[t,x]=ode45(@sim1,tspan,x0);
%
% Plot results
When I try to run the code, these errors pop up:
Not enough input arguments.
Error in sim1 (line 16)
p2dot=(Ft/(1+n^2*(I1/I)))+((R1*n^2*(1/I)*p(2))/(1+n^2*(I1/I)))+((n*(1/C1)*q(8))/(1+n^2*(I1/I)));
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 115)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in DSCSim1 (line 10)
[t,x]=ode45(@sim1,tspan,x0);
How would I go about trying to fix this? I don't exactly know how many or what input arguments I need in order to make the code run. I also don't understand the error I'm getting in sim1 line 16, or in DSCsim1 line 10. Any help would be greatly appreciated.
댓글 수: 2
madhan ravi
2020년 4월 6일
Would it be possible to upload the equations in Latex form?
Zachary Cooper
2020년 4월 6일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!