"Undefined function 'rk' for input arguments of type 'inline'." error

function r = rk(a, b, h, f)
n = (b-a)/h;
t = a;
w = 1/3;
for i = 1:n
kone = h * f(t,w);
ktwo = h * f(t+h/2,w+kone/2);
kthr = h * f(t+h/2,w+ktwo/2);
kfou = h * f(t+h,w+kthr);
w = w + (kone + 2*ktwo + 2*kthr + kfou)/6;
t = a + i*h;
fprintf('w=%f t=%f\n',w,t);
end
r = 0;
why does it always give me an error? my other function has exactly the same structure as this one and it works!!!!

 Respuesta aceptada

Make sure that this is stored in rk.m and that the file is on your MATLAB path. Use
which -all rk
to see if it is on your path.

7 comentarios

it says 'rk' not found. why is it not found? Its in the same folder as the one i mentioned that does work, and i didn't change the "current folder"
What shows up if you use this command:
ls r*
Make sure the file is rk.m not just rk and not rk.txt
ZhenQi
ZhenQi el 4 de Dic. de 2012
Editada: ZhenQi el 4 de Dic. de 2012
"rk.m"
Is it possible that your current folder is not on your MATLAB path, and that the older file that you mentioned as working is also in a different folder that is being piked up?
Is it possible that there is a space before the "r" in the "rk.m" you are seeing?
If you go in with your operating system graphics interface (Windows Explorer probably), and rename it, being sure to delete all characters of the name, and giving it rk.m as the new name, then does that solve the problem?
ok let me try it
haha ok now this is interesting.
i went into the path folder using the windows explorer, and NOTHING is there! not even the file that DOES work is there. is it hidden? how can this be! and i tried to open it again using matlab File->open->bla bla bla->rk and it IS there.
oh thank you i got it to work for some reason i quit the program, came back in, reassigned the folder path to what i had before and i magically works now

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion 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!

Translated by