File name a function argument
Mostrar comentarios más antiguos
Hello there,
I hope every body is doing file. I have two questions. I will be very grateful if any matlab advance user can reply me.
1. Could you please tell me how I can use file name (say, aba.txt, actually data in text file) as Argument in a Matlab Function?
2. Can I call .m file ( not function, just code) inside another .m file? If yes, could you please suggest me, how I can do that.
Thanks in advance Regards Shafi
Respuesta aceptada
Más respuestas (1)
Matt Tearle
el 2 de Abr. de 2011
1. the standard approach would be to use a string
function y = foo(fname)
fid = fopen(fname);
etc
Then call it with
x = 'abc.txt';
y = foo(x);
2. yes, just give the name of the script (without the .m extension) as a command, just like you'd run it at the command line.
1 comentario
Shafi
el 3 de Abr. de 2011
Categorías
Más información sobre File Operations 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!