How do i make this function write to the ode

1 回表示 (過去 30 日間)
Marcus Stürup
Marcus Stürup 2020 年 4 月 19 日
回答済み: Jyotsna Talluri 2020 年 4 月 22 日
Hey Fellas
I have a issue with a function where i want to share the thrust and fuelin with a ode45. when i run the program it says
"Unrecognized function or variable 'thrust'.
Error in fdsafafdafda (line 33)
thrust_stage1=thrust*1000;"
isnt the function sharing the thrust via the outputargument? how do i make it work.
function tryss
menu('how much fuel and thrust do you want? ', 'Falcon 9', ' too much fuel ','Too little fuel', ' too little thrust', 'custom');
function [thrust,fuelin]=choice(menu)
if menu ==1
%standard Falcon 9
thrust=7607;
fuelin=423;
elseif menu ==2
thrust=7607;
fuelin=1000;
elseif menu ==3
thrust= 7607;
fuelin=40;
elseif menu ==4
thrust=1600;
fuelin=423;
elseif menu==5
thrust=input('kN thrust? ');
fuelin=input('tons of fuel? ');
end
end
thrust_stage1=thrust*1000;
fuel=fuelin*1000;
thrust_stage2=934000; %standard
tid=[0.1 1500];
SB = [0,0,0];
T=(1:1500);
opt = odeset('event', @analyse);
[t,y] = ode45(@(t,y) stage1(t,y,T,thrust_stage1, thrust_stage2,fuel),tid,SB,opt);
end

採用された回答

Jyotsna Talluri
Jyotsna Talluri 2020 年 4 月 22 日
Here,you are not passing a valid input to the choice function.Pass the output from the menu function,the number of the chosen item to the choice function as below.
function tryss
ch = menu('how much fuel and thrust do you want? ', 'Falcon 9', ' too much fuel ','Too little fuel', ' too little thrust', 'custom');
[thrust,fuelin]=choice(ch);
thrust_stage1=thrust*1000;
fuel=fuelin*1000;
thrust_stage2=934000; %standard
tid=[0.1 1500];
SB = [0,0,0];
T=(1:1500);
opt = odeset('event', @analyse);
[t,y] = ode45(@(t,y) stage1(t,y,T,thrust_stage1, thrust_stage2,fuel),tid,SB,opt);
end
You need not define the function choice inside tryss.You can define in another .m file.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePoint Cloud Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by