How to export from Mathematica so that Matlab can see a variable name other than Expression1

조회 수: 5 (최근 30일)
I'm exporting a variable from Mathematica to disk in .mat format.
Later I want to read this in Matlab.
When I load the .mat file, my variable is called Expression1
How do I export it properly in Mathematica so that my original variable name is preserved?
(I don't know if this is possible. I can't find out how to do it when I search the mathematica help files)
Thanks,
Tom
  댓글 수: 2
dpb
dpb 2024년 8월 2일
I've not used Mathematica in 20+ yr, but reading the doc for Export, I don't see any option to set a variable name in the .MAT file by the syntax shown, either.
You can name the file and then use the function style of load to return in a struct that you can then rename the field(s) of programmatically may be about the best workaround I see.
You may be better off asking in a Mathematica newsgroup rather than here for arcane things that might be doable.
Tom
Tom 2024년 8월 2일
Yes, I did that and got the answer.
Here is a link to the fellow on stackexchange who pointed it out to me.
I had read the help page in mathematica, but I was being a bit thick and didn't realize it showed me how.
I'll post the link below.

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

채택된 답변

Tom
Tom 2024년 8월 2일
편집: Tom 2024년 9월 4일
From Stackexchange
Export["myFileName", "myVariableNameinMatlab" --> myVariableName]
where myVariableName is the name of the variable in Mathematica I'm exporting (no quotations)
and "myVariableNameinMatlab" is the variable name I wish to show up in Matlab when I load that file. (quotations needed).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by