How to subplot data in a given order?

조회 수: 13 (최근 30일)
EK
EK 2018년 10월 27일
댓글: EK 2018년 10월 29일
Hi, I have data file with physiology neuronal recording from 6 diffrent channels. I an plotting average cells response for each channel and sublot them in from 1:6. I am attaching figure here. But now I need subplot channels in a given order. For example ch = [6 4 2 1 3 5] Can anyone help? Many thanks Helen
for ch = [1 2 3 4 5 6]
subplot(2,6,ch);
concatenated_data = [];
concatenated_data = [concatenated_data, mean(chn_data{ch},2)];
plot((concatenated_data(20:end)),'-','DisplayName',channel_names, 'LineWidth', 3,'color', ([0 .0 .0]));
ylim([ymin ymax])
end
  댓글 수: 2
dpb
dpb 2018년 10월 27일
Why can't you just substitute [6 4 2 1 3 5] for [1 2 3 4 5 6] in the loop index array?
It would be "more better" to write it so you could just walk through any desired sequence by setting that sequence vector and not have to actually modify the code, but for a "once-only" use the specific data array is the simplest.
EK
EK 2018년 10월 29일
Thank you!

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

채택된 답변

Aquatris
Aquatris 2018년 10월 29일
Below modification will make the subplot in the order presented in the ch_order variable.
ch_order = [6 4 2 1 3 5];
for i = 1:length(ch_order)
ch = ch_order(i);
subplot(2,6,i);
concatenated_data = [];
concatenated_data = [concatenated_data, mean(chn_data{ch},2)];
plot((concatenated_data(20:end)),'-','DisplayName',channel_names, 'LineWidth', 3,'color', ([0 .0 .0]));
ylim([ymin ymax])
end
  댓글 수: 1
EK
EK 2018년 10월 29일
편집: EK 2018년 10월 29일
thanks a lot! it works :)

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by