Вопрос

all. I'm new to Matlab and I'm a bit stuck. The last piece of the puzzle to run my experiment is to get some human input (expert supervised system). As easy as this may sound, I just can't seem to figure this one out.

I need to display four images to the user, plus an additional fifth figure (button, or could even be another image, doesn't matter). The code should wait until the user clicks any one of those images/figures and should continue afterwards (closing the figures, too). Obviously, I'd need to know which figure was clicked.

GUI programming in Matlab doesn't seem to be documented clearly to me. Or perhaps it's just in a realm that I'm not talented with. It's definitely a lot more confusing than Visual Studio, that's for sure.

Thanks in advance for your time; I greatly appreciate it! :)

Это было полезно?

Решение 2

Use menu:

figure(1)
plot...
figure(2)
plot...
figure(3)
plot...
figure(4)
plot...

% this will create a menu of labeled buttons where the user can click
m = menu('Choose a figure','Figure 1','Figure 2','Figure 3','Figure 4','None');

% close all 4 figures
close(1:4)  %will close figures 1 to 4

% --------- your program from here on ---------
if m == 5
     display('You chose no Figure');
else
     display(['You chose Figure:' num2str(m)]);
end
%---------

menu will return a number which corresponds to the option that the user clicked on.

Другие советы

Could you make all five of the images into buttons? The 'CData' property of a button can be used to display an image on a MATLAB button. See the following links for an example and an explanation (that hopefully makes sense!).

http://www.mathworks.com/matlabcentral/fileexchange/2378-buttons/content/buttons.m

http://www.mathworks.com/support/solutions/en/data/1-16V03/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top