필터 지우기
필터 지우기

Concatenating data from structure array for plotting

조회 수: 10 (최근 30일)
Bob Thompson
Bob Thompson 2019년 1월 8일
편집: Stephen23 2022년 8월 19일
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
Stephen23 2019년 1월 8일
편집: Stephen23 2019년 1월 8일
  댓글 수: 9
Stephen23
Stephen23 2019년 1월 9일
편집: Stephen23 2019년 1월 9일
As I mentioned earlier, working with nested functions is not much fun.
You could try something like this:
fun = @(s) s.Zone(1).Values(1,4);
V = arrayfun(fun,files([files.Param]==condition))
Bob Thompson
Bob Thompson 2019년 1월 9일
편집: Bob Thompson 2019년 1월 9일
That should be sufficient for this, thanks.
And in the future I know better how to avoid this whole situation, so double thanks.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mehmet Burak Ekinci
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.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by