Hi, I have a dialogue box that asks the user what is needed to be plotted. I have 9 data sets and these successfully plot one/multiple data sets depending on the user selection. However if multiple data sets are selected, the first is correctly named in the legend but the remaining data is named 'data1', 'data2' etc.
How can the data be named after the correct name at that point in the if statement?
Thanks
plot_choice = {'Digitised Gaussean Beam', 'Digitised 2 Minute Shots', 'Interpolated Gaussean Beam Values', 'Interpolated 2 Minute Shot Values', 'Uncorrected Experiment Gaussean Beam', 'Uncorrected Experiment 2 Minute Shots', 'Corrected Experiment Gaussean Beam', 'Corrected Experiment 2 Minute Shots', 'Corrected Theoretical Gaussean Beam'};plot_choice_text = {'Select Values To Be Plotted:-'};[plot_choice_index,plot_choice_tf] = listdlg('PromptString', plot_choice_text, 'ListSize', [250 125], 'ListString', plot_choice, 'Name', 'Plot Selection');if plot_choice_tf == 0 warndlg('No Plot Selected', 'Warning!') returnenda1 = ismember(1, plot_choice_index);a2 = ismember(2, plot_choice_index);a3 = ismember(3, plot_choice_index);a4 = ismember(4, plot_choice_index);a5 = ismember(5, plot_choice_index);a6 = ismember(6, plot_choice_index);a7 = ismember(7, plot_choice_index);a8 = ismember(8, plot_choice_index);a9 = ismember(9, plot_choice_index);figure(1)hold onif a1 == 1 plot(x, y_gaussean_beam, 'r-o'); legend('Digitised Gaussean Beam'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a2 == 1 plot(x, y_2_minute_shots, 'b-o'); legend('Digitised 2 Minute Shots'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a3 == 1 plot(interp_x_array, interpolation_gaussean_beam, 'r.'); legend('Interpolated Gaussean Beam'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a4 == 1 plot(interp_x_array, interpolation_2_minute_shots, 'b.'); legend('Interpolated 2 Minute Shots'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a5 == 1 plot(our_delta, our_gaussean_beam, 'r*'); legend('Uncorrected Exp Gaussean Beam'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a6 == 1 plot(our_delta, our_2_minute_shots, 'b*'); legend('Uncorrected Exp 2 Minute Shots'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a7 == 1 plot(our_delta, our_gaussean_beam_corrected, 'r-*'); legend('Corrected Exp Gaussean Beam'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a8 == 1 plot(our_delta, our_2_minute_shots_corrected, 'b-*'); legend('Corrected Exp 2 Minute Shots'); legend('Location', 'southwest', 'AutoUpdate', 'off');endif a9 == 1 plot(our_delta, our_fwhm, 'g-*'); legend('Theoretical Gaussean Beam'); legend('Location', 'southwest', 'AutoUpdate', 'off');endxlabel('Focal Position (\mum)');ylabel('FWHM (\mum)');title('Digitised Defocus vs FWHM');x_axis_ticks = linspace(-120, 120, 13); %xaxis ticks between -120 to 120 spaced 20um apart
axis([-135 80 0 27]); %axes size [x1 x2 y1 y2]
xticks(x_axis_ticks);ax = gca;ax.YAxisLocation = 'origin'; %Centre y axis on the origin
hold off
Best Answer