Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Possibility to access/use whole structures
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi!
I made a structure with;
month(1)
month(2)
month(3) etc.
For example, I want to plot month(1:12).Q how can I do this?
댓글 수: 0
답변 (1개)
Guillaume
2016년 2월 22일
See Access multiple elements of a nonscalar struct array. In your case, assuming that the fields Q are scalar:
plot([month(1:12).Q])
댓글 수: 3
Guillaume
2016년 2월 22일
편집: Guillaume
2016년 2월 22일
It wasn't clear from your question whether Q was scalar (in which case you'd want a single plot for all the months) or a vector (in which case you'd want a plot per month).
In the latter case, the easiest is probably:
figure;
hold on;
arrayfun(@(m) plot(m.Q, m.Z), month);
Another option is to stuff the Q and Z in a single cell array and use comma separated list expansion to input arguments:
figure;
QZ = {month.Q; month.Z};
plot(QZ{:}); %Q and Z of each month must be the same size (or scalar)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!