I use Save and Get routinely in Mathematica. How can I get saved variables and functions from Mathematica into Matlab?

1 回表示 (過去 30 日間)
I use Save and Get routinely in Mathematica. How can I get saved variables and functions from Mathematica into Matlab?
  6 件のコメント
Walter Roberson
Walter Roberson 2019 年 6 月 5 日
Mathematica has an export to matlab facility.
Wayne McKinney
Wayne McKinney 2019 年 6 月 5 日
Yeah, from 1999. I have been trying all day to get it to work.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 6 月 5 日
file_in = 'diaboloid_aij.txt';
file_out = 'diaboloid_aij.m';
S = fileread(file_in);
Snew = regexprep(S, {'\[(\d+),', '(\d+)\]', '\[', '\]', 'Cos', 'Sin', 'Tan', 'Sec', '([-+*/])\s*$', '\)\s*$'}, {'(1+$1,', '1+$1)', '(', ')', 'cos', 'sin', 'tan', 'sec', '$1 ...', ');'}, 'lineanchors');
fid = fopen(file_out, 'w');
fwrite(fid, Snew);
fclose(fid);
clear diaboloid_aij %flush any saved versions of the file
Script diaboloid_aij is now ready to run after you have defined numeric values or symbolic names for the variables.
  4 件のコメント
Wayne McKinney
Wayne McKinney 2019 年 6 月 6 日
編集済み: Wayne McKinney 2019 年 6 月 6 日
Seems to work beautifully! I had to add ... after = on lines 108 and 152.
Walter Roberson
Walter Roberson 2019 年 6 月 6 日
Ah. The code I was working with originally would have taken care of that, but unfortunately I had some difficulty in getting it to match in "something that is not ) followed by any amount of whitespace followed by end of line"

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by