How can i set on/off some features of my function?

Hi everyone, I would like to describe my problem as follow ;for example i am running main code with pushbutton1 but before that I need to set some features(such as sendmail function) on or off. The reason to want that is get a adjustable Gui by user . I was researching about popup-menu to handle it with but couldnt find a touchable solution Anyone can give me some advice please ? Apriciate to any help Atas

 Réponse acceptée

I think a radio button or checkbox is more common. For those
chkSendMail = get(handles.chkSendMail, 'Value');
if chkSendMail
% Do stuff
end
radSendMail = get(handles.radSendMail , 'Value');
if radSendMail
% Do stuff
end
For a popup
popSendMail = get(handles.popSendMail , 'Value');
if popSendMail == 3 % Whatever item in the list it is....
% Do stuff
end

4 commentaires

Thank you for answering,
yeah now i satisfied to use radio button or checkbox instead of popup, looks much logic. in my code, i have sendmail function in 4 condition what i wish from checkbox(when i point out it) is just like putting a "%" on head of line which contain my sendmail function so can be done with your code above ?
Not sure what that means. A checkbox has only two conditions on or off, or check/unchecked, or 1/0. If there are 4 slightly different things you want to do with sendmail (like different recipients or attachments), then maybe you do need a popup. Or you could have 4 radio buttons but make sure the radio buttons are in a "button group". It's like a panel that makes sure that all the other radio buttons are deselected except the one you want.
sorry if been incomprehensible. i will try just one last time. the following codes shortly compare two photos and according to the reasons may send mail(sendmail) and also play something like alert(Fs). now i want to make those Fs and sendmail optional by user. Like if user set sendmail mod off there will be just alert . That is what actually i mean
vid=videoinput('winvideo');
cnt=1;
n=0;
for n=1:5:10;
im=getsnapshot(vid);
imwrite(im,['photo_' int2str(cnt) '.jpg']);
n=n+1;
cnt=cnt+1;
end
if true
A=imread('C:\Program Files\MATLAB\R2011a\bin\photo_1.jpg');
A=rgb2gray(A);
B=imread('C:\Program Files\MATLAB\R2011a\bin\photo_2.jpg');
B=rgb2gray(B);
end
Fs=2000;
s = wavread('Whistle.wav');
if true
object=B-A;
imwrite(object,'detected.jpg','jpg','Comment','My JPEG file');
if object~=0;
sound(s,Fs);
sendmail
end
end
end
end
Yep, my first set of code should work. Just replace your "if true" with an if that checks the value of whatever checkbox or radio button makes sense for that operation.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by