필터 지우기
필터 지우기

writing mfile using a mfile

조회 수: 2 (최근 30일)
Rajan
Rajan 2011년 10월 4일
Can any one pls give an example on how to write into an mfile using a mfile i.e mscript ??

답변 (2개)

Jan
Jan 2011년 10월 4일
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
Matt Tearle
Matt Tearle 2011년 10월 4일
With the single quote marks actually included, you mean?
fprintf(1, '''%s'' \n',a1{:});
Rajan
Rajan 2011년 10월 4일
yea Matt figured it out.thank you for the comments.

댓글을 달려면 로그인하십시오.


Matt Tearle
Matt Tearle 2011년 10월 4일
  댓글 수: 2
Rajan
Rajan 2011년 10월 4일
Thank you for the answer.
I am using R2009b.
Do u have any idea of how to do it in R2009b?
Jan
Jan 2011년 10월 5일
Editor = com.mathworks.mlservices.MLEditorServices;
methods(Editor)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by