Two questdlg with two switch

1 vue (au cours des 30 derniers jours)
Jose Rego Terol
Jose Rego Terol le 3 Déc 2019
Hi all,
I have this code to analyze spikes. I want to include a second question dialog that is prompted when the user selects ´Continue´. In this second question, I want to include two options: ´Yes´ and ´No´. ´Yes´ will do some staff and ´No´ will take the user to the previous question dialog.
May you help me?
I am using the questdlg and switch because the code was given to me in this way.
Best,
Jose
clear; close all; %format compact;
clc;
fileName = 'sample_3.mat';
load(fileName);
cont = 1;
mNum = 0;
mainDir = [cd '\Exported_ROI [' datestr(date,'yyyy-mm-dd') ']/'];
mkdir(mainDir);
while cont==1;
if mNum~=0;
% Continuation Option
ifCont = questdlg({['So far ' num2str(mNum) ' regions were measured for: '];...
['"' fileName '"'];...
['What do you want to analize?']}, ...
'Analizing Dialog', ...
'Foot signal of the current spike','Continue','Finish with the current file','');
else
ifCont = 'Foot signal of the current spike';
end
switch ifCont
case 'Foot signal of the current spike'
mNum = mNum+1;
f1=figure(1);
set(f1,'units','normalized','position',[0.05,0.05,0.9,0.9],'NumberTitle','off','MenuBar', 'None');
hold all;box off; grid on;
plot(x,y);%axis tight;
ylabel('Measured Data');
title('Select two points around a event', 'interpreter','none');
%% Two points to be selected
pan on;
pause();
pan off;
zoom on;
pause() % you can zoom with your mouse and when your image is okay, you press any key
zoom off; % to escape the zoom mode
pan on;
pause();
pan off;
[px_1, py_1, ~] = ginput (1);
%zoom out; % go to the original size of your image
% Plot the vertical line at the x
line([px_1 px_1], [min(y) max(y)], 'linestyle', '-', 'color', 'r');
% Show selected point on curve
[~, h1] = min(abs(px_1*ones(length(x),1)-x));
line(xlim, [y(h1) y(h1)], 'linestyle', '-', 'color', 'g');
hline(1)=plot(x(h1),y(h1),'ok');
% Plot the vertical line at the x
pan on;
pause();
pan off;
zoom on;
pause() % you can zoom with your mouse and when your image is okay, you press any key
zoom off; % to escape the zoom mode
pan on;
pause();
pan off;
[px_2, py_2, buttons] = ginput (1);
%zoom out; % go to the original size of your image
line([px_2 px_2], [min(y) max(y)], 'linestyle', '-', 'color', 'b');
% Show selected point on curve
[aux, h2] = min(abs(px_2*ones(length(x),1)-x));
line(xlim, [y(h2) y(h2)], 'linestyle', '-', 'color', 'g');
plot(x(h2),y(h2),'ok');
hold off;
pause(1)
%% Selected data within range:
X = x(h1:h2);
Y = y(h1:h2);
f2=figure(2);
set(f2,'units','normalized','position',[0.05,0.05,0.9,0.9],'NumberTitle','off','MenuBar', 'None');
hold all; box on; grid on;
plot(X,Y); axis tight;
title(['Measured ROI #' num2str(mNum)]);
%print('-dpdf',[mainDir 'ROI_No' num2str(mNum,'%d')]);
save([mainDir 'Foot Signal_No' num2str(mNum,'%d') '.mat'], 'X','Y')
case 'Continue'
close all;
mNum = mNum+1;
f1=figure(1);
set(f1,'units','normalized','position',[0.05,0.05,0.9,0.9],'NumberTitle','off','MenuBar', 'None');
hold all;box off; grid on;
plot(x,y);%axis tight;
ylabel('Measured Data');
title('Select two points around a ROI', 'interpreter','none');
%% Two points to be selected
zoom on;
pause() % you can zoom with your mouse and when your image is okay, you press any key
zoom off; % to escape the zoom mode
[px_1, py_1, ~] = ginput (1);
%zoom out; % go to the original size of your image
% Plot the vertical line at the x
line([px_1 px_1], [min(y) max(y)], 'linestyle', '-', 'color', 'r');
% Show selected point on curve
[~, h1] = min(abs(px_1*ones(length(x),1)-x));
line(xlim, [y(h1) y(h1)], 'linestyle', '-', 'color', 'g');
plot(x(h1),y(h1),'ok');
% Plot the vertical line at the x
zoom on;
pause() % you can zoom with your mouse and when your image is okay, you press any key
zoom off; % to escape the zoom mode
[px_2, py_2, buttons] = ginput (1);
%zoom out; % go to the original size of your image
line([px_2 px_2], [min(y) max(y)], 'linestyle', '-', 'color', 'b');
% Show selected point on curve
[aux, h2] = min(abs(px_2*ones(length(x),1)-x));
line(xlim, [y(h2) y(h2)], 'linestyle', '-', 'color', 'g');
plot(x(h2),y(h2),'ok');
hold off;
pause(1)
%% Selected data within range:
X = x(h1:h2);
Y = y(h1:h2);
f2=figure(2);
set(f2,'units','normalized','position',[0.05,0.05,0.9,0.9],'NumberTitle','off','MenuBar', 'None');
hold all; box on; grid on;
plot(X,Y); axis tight;
title(['Measured ROI #' num2str(mNum)]);
%print('-dpdf',[mainDir 'ROI_No' num2str(mNum,'%d')]);
save([mainDir 'ROI_No' num2str(mNum,'%d') '.mat'], 'X','Y')
case 'Finish with the current file'
cont = 0;
close all;
end
end

Réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by