Concatenating data from structure array for plotting
6 ビュー (過去 30 日間)
I have a structure array with several levels of depth that I am trying to extract a specific set of data from in order to plot it. The plan is to draw individual elements from several different fields, and then combine them into a single array for plotting. I know that normally structures can be concatenated using , but it doesn't seem to be working for this instance.
plot(x_values,[files([files.Param] == condition).Zone(1).Values(1,4)]);
Expected one output from a curly brace or dot indexing expression, but there were multiple results.
I know that the inner conditional statement is working, as I can extract it and get the appropriate logic matrix, but that means that I am looking at multiple elements of 'files' (which is exactly what I want to do), but they do not seem to be concatenating properly. Any suggestions would be appreciated.
Stephen23 2019 年 1 月 8 日
編集済み: Stephen23 2019 年 1 月 8 日
Nested structures do not allow that syntax, so the simplest solution is to use temporary variables to unnest those structures (temporary varaibles will not copy data in memory, so don't worry about using them).
その他の回答 (1 件)
Mehmet Burak Ekinci 2022 年 8 月 18 日
You may use custom matlab functions from file exchange to get values from nested struct arrays
See Answer in link for example.
Stephen23 2022 年 8 月 19 日
編集済み: Stephen23 2022 年 8 月 19 日
Or use the inbuilt GETFIELD and SETFIELD :
or use comma-separated lists:
and then you can avoid needing to use any third-party functions.
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!