フィルターのクリア

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 Center および File ExchangeProgramming についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by