How to fix my code for ode45

조회 수: 3 (최근 30일)
Marissa Farrell
Marissa Farrell 2020년 11월 18일
답변: Steven Lord 2020년 11월 19일
function_handle with value:
@(x,y)'(9*14^(1/2)*exp(-(2*x)/9)*sin((14^(1/2)*x)/9))/7)'
>> [x,y]=ode45(f,[0,25],0)
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
this is my ode45 code
[x,y] = ode45(odefun,xspan,y0)
[x,y] = ode45(odefun,xspan,y0,options)
[x,y,xe,ye,ie] = ode45(odefun,xspan,y0,options)
sol = ode45(___)
  댓글 수: 1
James Tursa
James Tursa 2020년 11월 18일
Please post your complete code, not just snippets.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2020년 11월 18일
Delete the single quotation marks.
This runs without error:
f = @(x,y) (9*14^(1/2)*exp(-(2*x)/9)*sin((14^(1/2)*x)/9))/7;
[x,y]= ode45(f,[0,25],0)
figure
plot(x, y)
grid
.
  댓글 수: 2
Marissa Farrell
Marissa Farrell 2020년 11월 18일
i still get this:
>> f = @(x,y) (9*14^(1/2)*exp(-(2*x)/9)*sin((14^(1/2)*x)/9))/7;
[x,y]= ode45(f,[0,25],0)
figure
plot(x, y)
grid
Insufficient number of outputs from right hand side of equal sign to satisfy assignment.
Star Strider
Star Strider 2020년 11월 18일
It ran for me without error in a script I use for MATLAB Answers problems.
Use it in a script (instead of your Command Window) and it should work.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Steven Lord
Steven Lord 2020년 11월 19일
I'm guessing you've defined a variable named ode45 that's preventing you from calling the ode45 function included in MATLAB. To check this, use the which function.
which -all ode45
If you see "ode45 is a variable" in the text displayed by that line of code you will need to rename or delete that variable before you will be able to call the ode45 function.

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by