MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Vugar
0

How to run scripts (not functions) with predefined user inputs?

Vugar
さんによって質問されました 2017 年 9 月 12 日
最新アクティビティ José-Luis
さんによって 編集されました 2017 年 9 月 12 日
There are several scripts in MATLAB with some user inputs (for example, x=input('Enter x: ')). The scripts cannot be executed automatically, since they require to manually define all user inputs. The only way I know to automatically execute the script with predefined inputs is by using pop-up history: I run script once, defining all inputs, and the next time I can simply highlight and launch the script with the previously defined inputs from pop-up history. The drawback of the descibed technique is that I cannot run the script with the predefined inputs from any other place (for example, I want to repeatedly run the script with predefined inputs from another script or function).
Does anybody know a solution differing from using matlab history?

  1 件のコメント

Use functions.

サインイン to comment.

1 件の回答

回答者: José-Luis
2017 年 9 月 12 日

  2 件のコメント

Vugar
2017 年 9 月 12 日
I read the article. The question is about how to define all user inputs simultaneously with launching the script. For example,to run the following code in command line: "MyScript input1 input2 ... inputn" - this is possible, as far as I know, only by using pop-up history
José-Luis
2017 年 9 月 12 日
Like Stephen said, use a function, that's what they're for.
Make your script a function. Any other solution is just a kludge.
A function can call other functions and/or scripts. Encapsulation will preserve your sanity so learn to use it.

サインイン to comment.



Translated by