Borrar filtros
Borrar filtros

Pre Selecting Figures to plot

21 visualizaciones (últimos 30 días)
David Harra
David Harra el 8 de Abr. de 2022
Respondida: Image Analyst el 8 de Abr. de 2022
When I run my script I have 10+ figures plotting. Rather than commenting them out, I was wondering if there is a way to set up at the beginning where I can select what plot or plots I would like. I was researching listdlg command but cant seem to implement this.
Thanks
Dave

Respuesta aceptada

Image Analyst
Image Analyst el 8 de Abr. de 2022
Try this:
for k = 1 : 10
choices{k} = sprintf('%d', k);
end
uiwait(helpdlg('On the next window, pick which you want to plot.'))
% Have specify which plots he wants to make
selectedIndexes = listdlg('ListString', choices)
if isempty(selectedIndexes)
% User clicked Cancel.
return;
end
% Do the selected plots:
for k = 1 : 10
if ismember(k, selectedIndexes)
subplot(3, 4, k);
plot(rand(10, 1), '-')
grid on;
caption = sprintf('Plot #%d', k);
title(caption)
end
end

Más respuestas (1)

Voss
Voss el 8 de Abr. de 2022
% some data you may or may not plot:
F = randn(10,1);
P = rand(20,1);
D = randi(50,25,1);
% prompt the plot selection:
plot_names = {'F' 'P' 'D'};
plot_idx = listdlg( ...
'Name','Select Plots', ...
'ListString',plot_names);
% make a logical vector saying whether to plot each plot:
do_plot = false(size(plot_names));
do_plot(plot_idx) = true;
% create the selected plots:
if do_plot(1)
figure();
plot(F);
title('F')
end
if do_plot(2)
figure();
plot(P);
title('P')
end
if do_plot(3)
figure();
plot(D);
title('D')
end

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by