How to load field values in struct file

23 ビュー (過去 30 日間)
In-chan Kim
In-chan Kim 2020 年 2 月 6 日
コメント済み: In-chan Kim 2020 年 2 月 6 日
I have a struct file, which says is a 1x1 struct with 1 field.
I used this command to load it:
structScenario1_indvoutputagg=load('Outputs/Agg/Scenario1_indvoutputagg');
How do I extract the data within to a cell format?
Capture.JPG

採用された回答

Stephen23
Stephen23 2020 年 2 月 6 日
編集済み: Stephen23 2020 年 2 月 6 日
S = load('Outputs/Agg/Scenario1_indvoutputagg');
C = S.ndvoutputagg;
Or, if there is only one variable in the file:
S = load('Outputs/Agg/Scenario1_indvoutputagg');
C = struct2cell(S);
C = C{1};
  1 件のコメント
In-chan Kim
In-chan Kim 2020 年 2 月 6 日
Great! Thanks very much worked a charm!
Can I also ask, how can I make into arrays a column of cell files?
timeatstayandtripcomp=Scenario1_indvoutputagg(1:r,88); %each row of the cell represents the variable for each ID
timeatstayandtripcomp=cell2mat(timeatstayandtripcomp);
I'd like each row in there to be an array. I've tried cell2mat but get Error using cat; I think it's because the number of columns for each row isn't necessarily the same.
I could maybe do a for loop, but I need to repeat this for many variables, so I'm wondering if there's a more efficient way of doing it
Capture.JPG

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

その他の回答 (0 件)

カテゴリ

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