Write a function that applies Euler's

조회 수: 1 (최근 30일)
Minh
Minh 2022년 12월 17일
답변: Walter Roberson 2022년 12월 17일
I'm working on the topic: "Write a function applying the Euler method, approximate function y(x): function [x,y]" but got an error at "Error in Ole2 (line 2)fxy = matlabFunction(f)"
code:
function [x,y] = Ole(f, xfirst, xlast, y0, N)
fxy = matlabFunction(f);
h = (xlast - xfirst)/N;
x = xfirst:h:xlast;
y = x;
y(1) = y0;
for i = 1:N y(i+1) = y(i) + h*fxy(x(i),y(i));
end
end
  댓글 수: 1
Torsten
Torsten 2022년 12월 17일
The reason for the error lies the way you call "Ole", not in the function code that you posted itself.

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

채택된 답변

Walter Roberson
Walter Roberson 2022년 12월 17일
I predict that you tried to run the code by pressing the green Run button, instead of going to the command line and invoking it passing in appropriate parameters, or having some code in a different file that invokes the function passing in appropriate parameters.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by