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 CenterFile Exchange에서 Point Cloud Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by