- Load the variable from the .file, attempt to it, and save it back to the file. You can use the -append option of save to avoid overwriting the other variables. Note that the -append option overwrites all of an existing variable with the same name; you cannot, for example -append 3 more array elements to an existing variables and expect that it will go from 1 x 3 to 1 x 6.
- Use a -v7.3 .mat file, and use matFIle() . Changes to the variable are automatically saved into the file. matFile can read -v7 .mat files but it must be a -v7.3 mat file in order to write to it.
How can I save just the values of a structure in a .mat file?
1 次查看(过去 30 天)
显示 更早的评论
I have 2 structures with 5 fields. I would like to save the values in a .mat file, and later on append the next values of the second structure into that file.
The structures are also a combination of strings and doubles.
0 个评论
回答(1 个)
Walter Roberson
2019-10-17
I would like to be sure that I understand what you are asking.
You have two structures that happen to have 5 fields each. You would like to store both structures into a single .mat file, ending up with two variables stored in the .mat file, one for each structure. Later, you would like to extend the second of those two structure variables in the .mat file. Are you extending by adding more fields, or are you extending by adding more elements -- for example extending a struct array of size 1 x 3 to a struct array of size 1 x 6 (each entry of which would have 5 fields) ?
If this is correct, then to extend a structure array inside a .mat file, there are two options:
0 个评论
另请参阅
类别
在 Help Center 和 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!