Need to create one graph with multiple subplots in a for loop.
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello! I am very new to MATLAB and was given this for loop to work with. My problem is that this code generates multiple graphs depending on how many neurons dff represents. Every time I put the subplot function into the code I still generate multiple graphs instead of just one. Any help would be greatly appreciated as a newbee to MATLAB!
M_dff = max(dff, [], 'all') + 0.01;
min_dff = min(dff, [], 'all') - 0.01;
for i=1:size(dff, 1)
fig = figure('pos', [283 602 1292 354]);
findpeaks(dff(i,:), 2, 'MinPeakHeight', threshold(i), 'MinPeakWidth', 2);
hold on
yline(threshold(i), 'r--', 'LineWidth', 4); hold on
title('\DeltaF / F of Cell ', 'FontSize', 14);
xlabel("Seconds"+newline+" ", 'FontSize', 14);
ylabel('\DeltaF / F', 'FontSize', 14);
ylim([min_dff M_dff]);
xlim([0 size(dff, 2)/2]);
pause(1)
% str_saveas = strcat('Cell_', int2str(i));
% saveas(fig, str_saveas, 'png');
%close all
end
0 Commenti
Risposta accettata
Voss
il 18 Lug 2023
Something like this?
% some random data, so the code runs:
dff = rand(3,10);
threshold = [0.2 0.35 0.25];
%
M_dff = max(dff, [], 'all') + 0.01;
min_dff = min(dff, [], 'all') - 0.01;
fig = figure('pos', [283 602 1292 354]);
N = size(dff, 1);
for i=1:N
subplot(1,N,i)
findpeaks(dff(i,:), 2, 'MinPeakHeight', threshold(i), 'MinPeakWidth', 2);
hold on
yline(threshold(i), 'r--', 'LineWidth', 4); hold on
title('\DeltaF / F of Cell ', 'FontSize', 14);
xlabel("Seconds"+newline+" ", 'FontSize', 14);
ylabel('\DeltaF / F', 'FontSize', 14);
ylim([min_dff M_dff]);
xlim([0 size(dff, 2)/2]);
end
Più risposte (0)
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!