hi,
i am having four 1x1 structures each contains 50 fields. what i need to do is subplot the 1st field from each structure, save the plot and do the same with the 2nd field from each structure and so on...
I am guessing i need to use a loop on each subplot, to plot each field, but how?

 채택된 답변

KSSV
KSSV 2018년 11월 13일
편집: KSSV 2018년 11월 13일

1 개 추천

% some random structure for demo
S(1).v = rand(10,2) ; S(1).name = 'one' ;
S(2).v = rand(10,2) ; S(3).name = 'two' ;
S(3).v = rand(10,2) ; S(3).name = 'three' ;
N = length(S) ; % length of the structure array
% plot
for i = 1:N
subplot(N,1,i)
plot(S(i).v(:,1),S(i).v(:,2))
title(S(i).name) ;
end

댓글 수: 2

MONTVERT ADAMS
MONTVERT ADAMS 2018년 11월 13일
can we do the same if the field names are dynamic, actually the field names are strings which will be needed to save the plots
KSSV
KSSV 2018년 11월 13일
편집: KSSV 2018년 11월 13일
Very much can be done......why not..check I hve edited the code.

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

추가 답변 (1개)

madhan ravi
madhan ravi 2018년 11월 13일
편집: madhan ravi 2018년 11월 13일

0 개 추천

p = structfun(@plot,S); %an example
p(1).Marker = 'o'; % number 1 represent field 1 marker likewise you can reate a loop for markers alone to differentiate
p(2).Marker = '+';
p(3).Marker = 's';
hold off

댓글 수: 1

MONTVERT ADAMS
MONTVERT ADAMS 2018년 11월 13일
i need to plot from different structures, into one plot, using subplot,
suppose i have four 1x1 structure lets say D1,D2,D3,D4. now each structure is having 50 fields suppose F1,F2,F3,F4,F5,F6,F8.....
so the plot will look like
SUBPLOT(D1.FA) SUBPLOT(D2,F1) SUBPLOT(D3,F1) SUBPLOT(D4,F1)
save it
SUBPLOT(D1,F2) SUBPLOT(D2,F2) SUBPLOT(D3,F2) SUBPLOT(D4,F2)
save it
*i havent writen the syntax of subplot but just trying to show you how the plot needs to look like
and these are spatial plots,
i just need to understand how to use a loop for the above

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2018년 11월 13일

편집:

2018년 11월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by