Assigning variables from command line

Hello,
For whatever reason, I want to be able to run an .m file (not a function) from the command window, and then add parameters on the same line in which I run the program.
for instance,
run file_I_want_to_run.m, true, false
Is there any way I can assign the boolean true and false to variables within the .m file?
The booleans dictate how a certain part of the .m file runs.
Thanks!

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 25일
편집: Azzi Abdelmalek 2016년 7월 25일

0 개 추천

You can set any parameter you want, then run your m-file
var1=1 % set your variable var1
var2=2 % var2
your_mFile % run your_mFie
running the m-file then assigning values to your variables doesn't make sens

댓글 수: 4

Neil Bhattacharjee
Neil Bhattacharjee 2016년 7월 25일
The point is that I want the user to enter the parameters themselves. I don't know whether it's going to be true or false.
Once we implement the code, we will be running this from the terminal window so it's imperative that all information stays on 1 line.
Any way you know of that I can accomplish this?
Steven Lord
Steven Lord 2016년 7월 25일
Yes -- make this code a function file instead of a script file, and have the user enter the parameters as input arguments to that function when they call it.
Azzi Abdelmalek
Azzi Abdelmalek 2016년 7월 25일
What is going to be true or false? why is it imperative to have all information in one line, and what information mean in your code?
John D'Errico
John D'Errico 2016년 7월 25일
It is time to learn how to write a function, instead of a script.

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

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

태그

질문:

2016년 7월 25일

댓글:

2016년 7월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by