Assigning variables from command line

16 visualizaciones (últimos 30 días)
Neil Bhattacharjee
Neil Bhattacharjee el 25 de Jul. de 2016
Comentada: John D'Errico el 25 de Jul. de 2016
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!

Respuestas (1)

Azzi Abdelmalek
Azzi Abdelmalek el 25 de Jul. de 2016
Editada: Azzi Abdelmalek el 25 de Jul. de 2016
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 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 25 de Jul. de 2016
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 el 25 de Jul. de 2016
It is time to learn how to write a function, instead of a script.

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by