フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how can I save from MATLAB

3 ビュー (過去 30 日間)
Ammy
Ammy 2018 年 1 月 26 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have generated a large number of matrices in MATLAB , all these are appear on the MATLAB comand window as;
Matrix 1 =
1 2 3
2 3 1
3 1 2
Matrix 2 =
1 2 3
3 1 2
1 3 2
and so on , How can I save all these in one file, and how can I used the resulting matrices in my latter work?
  3 件のコメント
Domanic
Domanic 2018 年 1 月 26 日
With your variables, you could save them using:
save('filename.mat','Matrix1','Matrix2',...)
However, as KSSV points out, it would be best to save these matrices as a single variable, or a cell array of matrices. If you're stuck with those matrix names, you can use the function 'eval' to automate saving.
Stephen23
Stephen23 2018 年 1 月 26 日
編集済み: Stephen23 2018 年 1 月 26 日
"If you're stuck with those matrix names, you can use the function 'eval' to automate saving."
Why bother? It is much simpler to use save and a regular expression:
save('file.mat','-regexp','Matrix\d+')
eval is what beginners use to force themselves into writing slow, complex, buggy code:
The best solution though, as others have already noted, is to not use numbered variables.

回答 (1 件)

Daniele Defilippi
Daniele Defilippi 2018 年 1 月 26 日
If the variables are inside the MATLAB workspace you can use the command
save('MyFileName.mat');
when you want to restore the variables you can use the command.
load('MyFileName.mat');

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by