How to save matlab coding output data in a file?

24 ビュー (過去 30 日間)
Sky Scrapper
Sky Scrapper 2019 年 2 月 8 日
コメント済み: Stephen23 2019 年 2 月 8 日
Hello,
I am working with matlab coding. I need to run the simulations for different models. For the 1st model, I run the simulation, it saves output in the workspace. but when i run the 2nd model, it saves the output file for the 2nd model. That is why i need to save the output for the 1st model to a file. So, i can store my outputs of all models.
can anyone please suggest me how to do?
  11 件のコメント
Sky Scrapper
Sky Scrapper 2019 年 2 月 8 日
it's showing error:
''Error using load
Number of columns on line 3 of ASCII file finaloutput.m must be the same as previous lines.''
Walter Roberson
Walter Roberson 2019 年 2 月 8 日
Do not save naming .m file as destination . Name a .mat file.

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

採用された回答

Omer Yasin Birey
Omer Yasin Birey 2019 年 2 月 8 日
編集済み: Omer Yasin Birey 2019 年 2 月 8 日
  14 件のコメント
Sky Scrapper
Sky Scrapper 2019 年 2 月 8 日
ok thanks a lot.
Stephen23
Stephen23 2019 年 2 月 8 日
"Don't forget to write '-append' at the end otherwise it will write the variables over your existing variables. Meaning that your old variables will be deleted."
Yet that is exactly what the -append option does for .mat files: it overwrites existing variables of the same name, which confuses a lot of beginners (it would be better named overwrite or something similar). This is explained in the save help (and easily checked with a few tests).
The suggested answer to use matfile is pointlessly complex for this trivial task. Much simpler to use save in a loop, generating the filename each time:

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by