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일

1 개 추천

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.

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

카테고리

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

질문:

2014년 10월 2일

댓글:

2014년 10월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by