not enough input data

2 ビュー (過去 30 日間)
Alessandro Papetti
Alessandro Papetti 2021 年 3 月 21 日
編集済み: Stephan 2021 年 3 月 21 日
I don't understand why MATLAB says to me that there are not enough input data in this code. Can you help me?
function dydt=Step1(t,y)
Q=1000;
F=8;
m=100;
cp=2.5;
Ti=300;
T=y(1);
dTdt=(Q/(m*cp))-(F/m*cp)*(T-Ti);
dydt=[dTdt]';
  2 件のコメント
Christopher McCausland
Christopher McCausland 2021 年 3 月 21 日
How are you calling this function? I am guessing that you do not pass Step the inputs its looking for (t,y). Here is more information. https://uk.mathworks.com/matlabcentral/answers/53100-not-enough-input-arguments. Let us see how you call the function, there are some other problems that can cause the same issue like MATLAB expecting the input arguments in a specific format.
Alessandro Papetti
Alessandro Papetti 2021 年 3 月 21 日
sure, here it is the call
clc
clear all
close all
format compact
format short g
Q=1000;
F=8;
m=100;
cp=2.5;
Ti=300;
%steady state solution (of T)
Toutss=(Q/(F*cp))+Ti;
tspan=[0: 150];
T0=300;
options=odeset('RelTol',1e-8,'AbsTol',1e-12);
[t,T]=ode15s(@(t,T)Step1(t,T,Q,F,cp,Ti,m),tspan,T0,options);
T1=T(:,1);
tspan=[150 300];
T00=max(T); %è uguale a Toutss
[t1,T2]=ode15s(@(t1,T2)Step2(t1,T2,Q,F,cp,Ti,m),tspan,options);
plot(t,T1,'b',t1,T2,'r');

サインインしてコメントする。

採用された回答

Stephan
Stephan 2021 年 3 月 21 日
編集済み: Stephan 2021 年 3 月 21 日
Note that i used the same function for step2 like step1 to make it work - replace step2 with the correct function. Also i assumed that T00 is the initial value for step2 - you shpould check this for correctness:
format compact
format short g
% Call nested function
myODE
function myODE
% constants
Q=1000;
F=8;
m=100;
cp=2.5;
Ti=300;
%steady state solution (of T)
Toutss=(Q/(F*cp))+Ti;
% Step 1
tspan=[0,150];
T0=300;
options=odeset('RelTol',1e-8,'AbsTol',1e-12);
[t,T]=ode15s(@Step1,tspan,T0,options);
% Step 2
T1=T(:,1);
tspan=[150 300];
T00=max(T); %è uguale a Toutss
[t1,T2]=ode15s(@Step2,tspan,T00,options);
plot(t,T1,'b',t1,T2,'r');
function dydt=Step1(~,y)
T=y(1);
dTdt=(Q/(m*cp))-(F/m*cp).*(T-Ti);
dydt=dTdt';
end
function dydt=Step2(~,y)
T=y(1);
dTdt=(Q/(m*cp))-(F/m*cp).*(T-Ti);
dydt=dTdt';
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by