Save vector to m-file

11 visualizaciones (últimos 30 días)
Tomas
Tomas el 2 de Oct. de 2014
Comentada: Oleg Komarov el 3 de Oct. de 2014
Hi. I have a task where I am to create a file called bestPath.m which in turn should include a vector called bestPath. I have searched the net, but no luck. Thanks in advance.
  2 comentarios
dpb
dpb el 2 de Oct. de 2014
Not a good idea...the resulting variable will alias the function name--altho I suppose that could be the intent??
As for the mechanics of doing so, what's the specific problem?
Tomas
Tomas el 2 de Oct. de 2014
Yes, that is the intent. It's a task I've gotten from school :).

Iniciar sesión para comentar.

Respuestas (1)

Oleg Komarov
Oleg Komarov el 2 de Oct. de 2014
Editada: Oleg Komarov el 2 de Oct. de 2014
Since R2014a you can use matlab.io.saveVariablesToScript():
a = rand(10);
matlab.io.saveVariablesToScript('test.m','a')
Check the content of the .m file with
edit test
Calling test from the command line will evaluate a into the workspace.
  2 comentarios
Tomas
Tomas el 2 de Oct. de 2014
Thank you very much! :)
Oleg Komarov
Oleg Komarov el 3 de Oct. de 2014
If my answer solves your problem, please accept it.

Iniciar sesión para comentar.

Categorías

Más información sobre Testing Frameworks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by