Write a function that applies Euler's
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Minh
il 17 Dic 2022
Risposto: Walter Roberson
il 17 Dic 2022
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 Commento
Torsten
il 17 Dic 2022
The reason for the error lies the way you call "Ole", not in the function code that you posted itself.
Risposta accettata
Walter Roberson
il 17 Dic 2022
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Fluid Dynamics in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!