フィルターのクリア

How to save contents of nonscaler structure?

8 ビュー (過去 30 日間)
Greydon Gilmore
Greydon Gilmore 2017 年 9 月 18 日
コメント済み: Stephen23 2017 年 9 月 18 日
Hi There, I have a nonscalar structure of data that I wish to save. It seems the usual call to save does not work on nonscaler structures. Does anyone have a workaround?
My current structure is 1x4, with the second dimension being associated with different recording channels from my study struct(1).raw struct(2).raw ec.
Thank you in advance
  2 件のコメント
OCDER
OCDER 2017 年 9 月 18 日
What is the "usual call" that you are using? I think this Q&A might help: https://www.mathworks.com/matlabcentral/answers/29282-non-scalar-structures
Stephen23
Stephen23 2017 年 9 月 18 日
"It seems the usual call to save does not work on nonscaler structures."
Yes it does:
save('nameOfFile.mat','nameofStruct')
Why do you think that this does not work?

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 18 日
You can just save() the structure. You do not need to use the -struct flag to save(). The -struct flag of save is for the particular case where you have a (scalar) structure whose individual fields you want to create as variables in a .mat file.
datastruct = load('YourMatFile.mat');
save('YourNewMatFile.mat', 'datastruct', '-struct')
load() of a .mat stored into a variable creates a scalar structure with one field for each variable stored in the .mat file, and save() with the -struct flag does the opposite, saving the individual fields into individual variables in a .mat file.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by