plot with for loop
Mostra commenti meno recenti
Hello everyone,
i have a 3D matrix, which where each colums represent a different channel (1:32), each rows is a single time point and the third dimension is a set of repeated stimulus (or trials, more or less 120). the final matrix is a a 2000x 32x120.
I would like to have the same plot you see in the code below, repeated every time for each comlums listed in the variable "range_of_chan = (10:20)" -> as for this example, I would like to get 21 different plots. Moreover, I would like that any of this plot to have a name according to the channel being plotted (ex: Single channel mean LFP n° 17) and so on. The same goes for the saving.
Maybe, the easiest way would be to have a for loop running. Could anyone of you give me some piece of code suitable for this case?
Thanks so much in advance for any help!
%% mean LFP [use TD_32 to plot]
mean_LFP_fil = mean(TD_32, 3);
%% features extraction and single channel selection [plot 2, 3]
range_of_chan = (10:20);
select_ch = 17; % type the channel of interest
[M,I] = min(mean(TD_32(:,select_ch,:),3));% principal peak amplitude and latency
%% plot 2 A [single channel mean LFP]
pr_peak_amp = M*10e13;
pr_peak_lat = I;
fig_name_3 = 'Single channel mean LFP';
figure(3)
plot(Time_vec, mean(TD_32(:,select_ch,:),3))
title(fig_name_3)
hold on
plot(get(gca,'xlim'), [0 0], 'k--')
plot([0 0], get(gca,"YLim"), 'k--')
plot([0 0]+.5,get(gca,'ylim'),'k--')
xlabel('Time (s)'), ylabel('activity (\muV)x100')
xline(5000,'--r')
text(I, 0, sprintf('Principal peak latency: %f ', pr_peak_lat))
plot(I, M,'-','MarkerSize',8,'Color','b')
text(I, M, sprintf('Principal peak amplitude: %f ', pr_peak_amp))
plot(I, M,'o','MarkerSize',6,'Color',[1 0 0])
set(gca,"XLim")
saveas(gcf,[main_folder,subfolder,fig_name_3],'png')
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Descriptive Statistics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
