필터 지우기
필터 지우기

how could I use subplot function to squeeze 12 existing graphs into 2 pages of 2x3

조회 수: 4 (최근 30일)
I plotted 12 hourly velocity profiles using the following codes
if true
%
h = 2.5:2:40.5;
for a = date1126+12:date1126+23; % second tidal cycle of the day is selected by observing mag_ts
if and(a>=date1126+16,a<=date1126+22);% flood tide
plot(East_hrAve(:,a),h)
set(gca,'XTick',linspace(0,1.6,9)); % set x min and max and steps
set(gca,'XTickLabel',[0:0.2:1.6]); % set labels
xlim([0 1.6]);
else % ebb tide
plot(East_hrAve(:,a),h)
set(gca,'XTick',linspace(-1.6,0,9)); % set x min and max and steps
set(gca,'XTickLabel',[-1.6:0.2:0]); % set labels
xlim([-1.6 0]);
end
xlabel('Current East Velocity (ms^{-1})');
ylabel('Height above seabed (m)');
end
If the codes above are too complicated, I have simplified them to the ones below:
h = 2.5:2:40.5;
for a = date1204:date1204+12-1;% 1st cycle of the day is selected by observing mag_ts
figure;
plot(East_hrAve(:,a),h);
set(gca,'XTick',linspace(-1,1,11)); % set x min and max and steps
set(gca,'XTickLabel',-1:0.2:1); % set labels
xlim([-1 1]);
xlabel('Current East Velocity (ms^{-1})')
ylabel('Height above seabed (m)')
end
end
I would like to subplot every 6 graphs into a page of 2x3 but am not sure how to do it using subplot(2,3,__). There are 12 graphs above. You may alter my codes to create subplot or you may add a few lines after my codes to rearrange the existing velocity profiles into subplot. Many thanks.

채택된 답변

MHN
MHN 2016년 3월 13일
편집: MHN 2016년 3월 13일
h = 2.5:2:40.5;
i=1; % ADD THIS LINE
figure; % ADD THIS LINE
for a = date1204:date1204+12-1;% 1st cycle of the day is selected by observing mag_ts
if mod(i,7)==0 % ADD THIS LINE
i=1; % ADD THIS LINE
figure; % ADD THIS LINE
end % ADD THIS LINE
subplot(3,2,i) % ADD THIS LINE
i = i+1; % ADD THIS LINE
plot(East_hrAve(:,a),h);
set(gca,'XTick',linspace(-1,1,11)); % set x min and max and steps
set(gca,'XTickLabel',-1:0.2:1); % set labels
xlim([-1 1]);
xlabel('Current East Velocity (ms^{-1})')
ylabel('Height above seabed (m)')
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by