Add new data into existing mat file
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
How to add new data in the existing mat file?
採用された回答
Stephen23
2016 年 9 月 28 日
save(filename,variables,'-append')
and describes it as " save(filename,variables,'-append') adds new variables to an existing file. If a variable already exists in a MAT-file, then save overwrites it. The variables argument is optional."
11 件のコメント
Hazel Sialongo
2016 年 9 月 28 日
I want to add data not to overwrite the data.
"I want to add data not to overwrite the data."
Lets read the line from the documentation more carefully then: "adds new variables to an existing file"
Here is an example of using the -append option, exactly like my answer states:
>> X = 1:3;
>> Y = 4:6;
>> save('test','X','Y')
>> Z = 7:9;
>> save('test','Z','-append')
>> S = load('test.mat')
S =
X: [1 2 3]
Y: [4 5 6]
Z: [7 8 9]
So the answer that I gave you worked perfectly: it appended the new data without overwriting anything. Did you actually try it? Does this do what you want?
If you want to append data to an array in the mat file then the easiest way is to use matfile, which lets you "Access and change variables directly in MAT-files, without loading into memory", as is explained here:
Hazel Sialongo
2016 年 9 月 28 日
But the data is from the gui edit toolbox.
blues
2019 年 10 月 23 日
Hi Stephen,
What if I want to add a data to the existing variables X and Y in your example? Let's say, I want to add X = 10:15; and Y = 20:25; in the test.mat file, how can I do this?
Stephen23
2019 年 10 月 24 日
- load, concatenate, save, or
- use matfile.
If using option 1. remember to load into an output variable rather than directly into the workspace.
blues
2019 年 10 月 24 日
Hi Stephen,
Could you give me suggestion on the following example?
I have a data in the following format: (i, j, k, val) where i, j, k are variables and val is the corresponding data at i, j, k values. I want to save the .mat file in the (i, j, k, val) format, so that my .mat files looks like:
(0, 0, 0, 1.5E-02)
(0, 0, 1, 2.5E-05)
...........................
(5, 5, 5, 4.5 E-05)
How can I create this type of .mat file?
Actually these data are the octant of a 11 by 11 by 11 matrix (isotropic cubic matrix). I would like to have a full-size matrix using the symmetry property of the octant. I want to save the octant data in a .mat file so that I could iterate over the 8 possibilities to make a full size matrix.
Stephen23
2019 年 10 月 25 日
Yahya Barghash
2020 年 4 月 12 日
thanks stephen you are a hero
zein
2021 年 4 月 27 日
how to add data to the saved variable without overwrites the old saved data?
Abhishek Kumar
2021 年 8 月 25 日
I have the same problem, I don't want it to overwrite either, I need to save multiple outputs from different run to the same file.
Stephen23
2021 年 8 月 25 日
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Workspace Variables and MAT Files についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
