how to pass parameters to a .m file in matlab command window?

5 ビュー (過去 30 日間)
madhu
madhu 2012 年 9 月 12 日
I have a .m file which requires some parameter to execute a function in it. I want to execute that .m file through command window. Now how to pass the parameter to that m file..?
  1 件のコメント
Jan
Jan 2012 年 9 月 12 日
Is the M-file a script or a function?

サインインしてコメントする。

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
編集済み: Azzi Abdelmalek 2012 年 9 月 12 日
If your parameters are in workspace, your m file will recognize them
If this m file is used many times, I recommand to use a function
  4 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
If file1 is your m file name and needs parameters a,b and c
>>a=10;b=12;c=14 %your parameters
>>file1
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 9 月 12 日
編集済み: Azzi Abdelmalek 2012 年 9 月 12 日
No; it's not possible. if your m file uses a variable x, you have to affect a value to x
>> x=10
>>file1

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by