undefined function 'f'
Mostra commenti meno recenti
tmesh = linspace(0,pi/2,5);
solinit = bvpinit(tmesh, @f);
sol = bvp4c(@odefun, @bcfun, solinit);
plot(sol.x, sol.y, '-o');
FUNCTION
function dzdt = odefun(t,z)
dzdt = zeros(2,1);
dzdt = [z(2)+z(1)];
end
% boundary conditions
function res = bcfun(za, zb)
res = [za(1) zb(pi/2)-2]
end
% Initial guess
function g = f(t)
g = [sin(t) cos(t)];
end
error unrecognized function or variable 'f'
3 Commenti
KSSV
il 31 Mar 2020
Did you save the function in the working folder?
Walter Roberson
il 31 Mar 2020
If you stored those three functions together in one file, and had the script in another file, then the script would only be able to see the first function inside the file of functions. Only the first function in a file of functions is visible to the outside normally; the rest are private implementations only for use by that function (typically)
Titas Chattopadhyay
il 31 Mar 2020
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Software Development Tools 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!
