so i got a function which i did as home work a few days ago tested it ,it ran ,now it doesn't want to run anymore i don't know how to fix it ,because i want to do a few more examples of ode45 and i get same error . The files have not been opened/modified since i wrote/tested them .
the function (which is saved correctly)
function dy=ec1L10(x,y)
dy=4*exp(0.8*x)-0.5*y
and the script
[x y]=ode45('ec1L10',0:0.25:4,2);
plot(x,y);grid on ; axis tight;

 채택된 답변

Star Strider
Star Strider 2020년 12월 10일

2 개 추천

To use your original construction, the single quotes are no longer acceptable..
Instead:
[x y]=ode45(@ec1L10,0:0.25:4,2);
would work.
However ‘ec1L10’ can be written as an anonymous function:
ec1L10 = @(x,y) 4*exp(0.8*x)-0.5*y;
so the rest of that code becomes:
[x y]=ode45(ec1L10,0:0.25:4,2);
plot(x,y);
grid on
axis tight
.

댓글 수: 4

Opariuc Andrei
Opariuc Andrei 2020년 12월 10일
i still get the too many input error , i tried running with and without @ ,same error
Star Strider
Star Strider 2020년 12월 10일
The problem is that you have your own ‘ode45’ function (or script, although if it is a script, that would likely throw a different error) that is overshadowing the MATLAB ode45 function.
The solution is to rename yours to something that does not overshadow any MATLAB function.
I must leave that to you.
Opariuc Andrei
Opariuc Andrei 2020년 12월 10일
편집: Opariuc Andrei 2020년 12월 11일
thx ,you saved me .I wanna buy you a beer :)
Star Strider
Star Strider 2020년 12월 11일
As always, my pleasure!
Thank you! Maybe some day ...

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

추가 답변 (1개)

Steven Lord
Steven Lord 2020년 12월 10일

2 개 추천

Let's check if you're using the ode45 function included in MATLAB. What does this function show? It should show just one function inside the toolbox/matlab/funfun subdirectory under matlabroot.
which -all ode45
/MATLAB/toolbox/matlab/funfun/ode45.m

댓글 수: 3

Opariuc Andrei
Opariuc Andrei 2020년 12월 10일
Steven Lord
Steven Lord 2020년 12월 11일
Rename or remove D:\Matlab saves\ode45.m.
Opariuc Andrei
Opariuc Andrei 2020년 12월 11일
i removed and all my ode45 work fine . thx :)

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

카테고리

제품

릴리스

R2020a

태그

질문:

2020년 12월 10일

댓글:

2020년 12월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by