Save vector to m-file

조회 수: 15 (최근 30일)
Tomas
Tomas 2014년 10월 2일
댓글: Oleg Komarov 2014년 10월 3일
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
dpb
dpb 2014년 10월 2일
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 2014년 10월 2일
Yes, that is the intent. It's a task I've gotten from school :).

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

답변 (1개)

Oleg Komarov
Oleg Komarov 2014년 10월 2일
편집: Oleg Komarov 2014년 10월 2일
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
Tomas
Tomas 2014년 10월 2일
Thank you very much! :)
Oleg Komarov
Oleg Komarov 2014년 10월 3일
If my answer solves your problem, please accept it.

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

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by