Write a function that applies Euler's

1 次查看(过去 30 天)
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