ode45 not enough input argument
Show older comments
Hi everyone, i have a problem with an ode function, i show you the code:
%Ode function:
function dTdt=ode1(t,T,d,e)
dTdt=d-e*T
return
%main code
T0=293;
T1=400;
Tf2=293;
a=0.2;
tchange=(T1-T0)/a;
for t=1:(tchange)+1
Tf(t)=T0+a*(t-1);
d=(Tf(t)-Tf2)/(R*C)
e=-2/(R*C)
[t,T] = ode45(ode1,[0 336],293,d,e)
end
Matlab says to me:
Error using ode1 (line 2) Not enough input arguments.
Error in Untitled (line 27) [t,T] = ode45(ode1,[0 336],293,d,e)
i know that i have to put some value for d and e, but how can i do if they change every step because they are in a for cycle? What else is wrong? Please please help me, i can't do anything by myself!
Accepted Answer
More Answers (2)
You need to vectorise your inputs to ode1 as below:
%Ode function:
function dTdt = ode1(t,T,d,e)
becomes
function dTdt = ode1(t,Y)
Y(1) = T;
Y(2) = d;
Y(3) = e;
3 Comments
saramatlab
on 8 Sep 2014
Andy L
on 8 Sep 2014
A few things to consider:
- When is T declared?
- When is Y declared?
- Should T be a vector?
- How are you storing the results of your optimisations?
saramatlab
on 8 Sep 2014
saramatlab
on 9 Sep 2014
0 votes
Categories
Find more on Ordinary Differential Equations 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!