Borrar filtros
Borrar filtros

writing mfile using a mfile

2 visualizaciones (últimos 30 días)
Rajan
Rajan el 4 de Oct. de 2011
Can any one pls give an example on how to write into an mfile using a mfile i.e mscript ??

Respuestas (2)

Jan
Jan el 4 de Oct. de 2011
This is not complicated:
FID = fopen(fullfile(tempdir, 'MyFunction.m'));
if FID < 0, error('Cannot open file'); end
fprintf(FID, 'function out = MyFunction(in)\n');
fprintf(FID, 'disp(in);\n');
fprintf(FID, 'out = clock;\n');
fclose(FID)
But creating M-files dynamically is a critical task. Are you really sure, that this is an efficient method to solve your problem?
  6 comentarios
Matt Tearle
Matt Tearle el 4 de Oct. de 2011
With the single quote marks actually included, you mean?
fprintf(1, '''%s'' \n',a1{:});
Rajan
Rajan el 4 de Oct. de 2011
yea Matt figured it out.thank you for the comments.

Iniciar sesión para comentar.


Matt Tearle
Matt Tearle el 4 de Oct. de 2011
  2 comentarios
Rajan
Rajan el 4 de Oct. de 2011
Thank you for the answer.
I am using R2009b.
Do u have any idea of how to do it in R2009b?
Jan
Jan el 5 de Oct. de 2011
Editor = com.mathworks.mlservices.MLEditorServices;
methods(Editor)

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by