Writing a variable and reading it elsewhere, how to do that?

1 回表示 (過去 30 日間)
Weia Reinboud
Weia Reinboud 2016 年 3 月 14 日
編集済み: Image Analyst 2016 年 3 月 14 日
After running a programm I have a the end a set of coordinates like Z=[0.4, 0.9; 1.3, 1.4; 2.0, 2.2] I like to use Z in another programm but I do not understand the details of read and write functions. Never done that before...

採用された回答

Image Analyst
Image Analyst 2016 年 3 月 14 日
To save it
save(fullFileName, 'Z');
Then, to load it in your other program
storedStructure = load(fullFileName);
Z = storedStructure.Z;
You can save multiple variables if you want, just list them
save(fullFileName, 'Z', 'myvar', 'someOtherVar');
  2 件のコメント
Weia Reinboud
Weia Reinboud 2016 年 3 月 14 日
Thanks, it works. Even simpler with save('Z').
Image Analyst
Image Analyst 2016 年 3 月 14 日
編集済み: Image Analyst 2016 年 3 月 14 日
You're giving the filename the same name as your variable, and not specifying any variables at all. So it will save all the variables in scope at the time in your workspace (not just Z) into a file called 'Z.mat'. If you want to do that, that's OK. Personally I like to be more explicit, but as long as you've commented it well, it will work. If we're done, then can you "Accept this Answer".

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by