fzero implicit functions - how to make recursive function handles
Mostra commenti meno recenti
I've been trying to implement a discrete ODE solver, but my iterations require an implicit function (f2), which also depends on the output of another function(f1)'s output with it's value as that function's input (i.e., f2(x) = ...f2(x). The function f1 will be an arbitrary handle which is the ODE.
Now, I do know that f2 will not be able to assign itself a handle, because f2 doesn't exist in the first place to refer to itself. But I do need this kind of a recursion because my implicit function demands it.
A simple version of the relevant part of the code is as follows, I've made f1 a sine, typically, it will be an input.
function x2 = fn(x)
f1 = @(x) sin(x);
f2 = @(x) x+f1(x)+f1(f2(x));
x2 = fzero(f2,x);
end
What would be the proper way to write line 3?
Thanks in advance.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!