Input argument "y" is undefined.

16 Ansichten (letzte 30 Tage)
Nimco
Nimco am 10 Aug. 2012
Hi
I am using the ode45 and I have been have one error message which I have tried to get get rid of but it still keeps coming up.
Input argument "y" is undefined.
Error in ==> trombe11 at 14
Tf1 =((y-b)-s1/Uc)*exp(-Ac*Uc*F/(m*cp))+(b+s1/Uc);
My m file program is:
function [dy] = trombe11(t,y )
Ac=0.2014;
Ar=2.2;
Aw=0.32;
Uc=3.1;
Uw=5.68;
Ut=1.03;
rho=1.23;
m =0.01353;
cp=1.003;
F=0.83;
b=8;
s1=15.68;
Tf1 =((y-b)-s1/Uc)*exp(-Ac*Uc*F/(m*cp))+(b+s1/Uc);
dy(1)=((Tf1-y)*0.011)/3.96 -((Ut*Ar+Uw*Aw)*(y-b)/(rho*cp*3.96));
The y value is the only parameter which is changing all the others are constants.
I also get a ~ sign on the t on the first line.
my ode function on the command space is:
>> yo=15;
>> tspan=[0:1:4];
>> [t,y]=ode45(@trombe11,tspan,yo);
>> plot(t,y);
The graph which I get is wrong.
Can anyone please suggest to me what I could do to eliminate this error.
Any help will be much appreciated
  1 Kommentar
Walter Roberson
Walter Roberson am 15 Aug. 2012
Could you explain further about "I also get a ~ sign on the t on the first line." ??

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Wayne King
Wayne King am 10 Aug. 2012
Bearbeitet: Wayne King am 10 Aug. 2012
I have no problem running this code:
yo=15;
tspan=[0:1:4];
[t,y]=ode45(@trombe11,tspan,yo);
plot(t,y)
Make sure that trombe11.m is saved in a folder that is on your MATLAB path. If you have it saved in c:\mfiles for example, then use
>>addpath 'c:\mfiles'
or the
>>pathtool
to add the folder.
As far as the plot not being correct, I don't know how we can address that without more details about what you expect to see.
  2 Kommentare
Walter Roberson
Walter Roberson am 10 Aug. 2012
Nimco replied,
Thank you for your help, I saved my work on MATLAB folder, but not MATLAB path. Are they the same thing?
I get the error reading when I press the publish icon in the m file but the program still runs.
m file
function [dy] = trombe11(t,y )
Ac=0.2014;
Ar=2.2;
Aw=0.32;
Uc=3.1;
Uw=5.68;
Ut=1.03;
rho=1.23;
m =0.01353;
cp=1.003;
F=0.83;
b=8;
s1=15.68;
Tf1 =((y-b)-s1/Uc)*exp(-Ac*Uc*F/(m*cp))+(b+s1/Uc);
dy(1)=((Tf1-y)*0.011)/3.96 -((Ut*Ar+Uw*Aw)*(y-b)/(rho*cp*3.96));
Input argument "y" is undefined.
Error in ==> trombe11 at 14
Tf1 =((y-b)-s1/Uc)*exp(-Ac*Uc*F/(m*cp))+(b+s1/Uc);
Command space
>> yo=15;
>> tspan=[0:1:4];
>> [t,y]=ode45(@trombe11,tspan,yo);
>> plot(t,y);
When I call the ode, I get a graph where y comes down with increasing time, but I am looking for the graph where y values increase with time.
Can anyone please suggest to me, what I could do solve this problem
Walter Roberson
Walter Roberson am 15 Aug. 2012
Don't press the "publish" icon!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by