undefined function 'f'
Mostrar comentarios más antiguos
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 comentarios
KSSV
el 31 de Mzo. de 2020
Did you save the function in the working folder?
Walter Roberson
el 31 de Mzo. de 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
el 31 de Mzo. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Software Development Tools en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
