Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Tricky if statement

Subject: Tricky if statement

From: machatsk

Date: 12 Aug, 2010 13:44:08

Message: 1 of 5

Hello all,
    I have a GUI with 3 checkboxes that represent data types for chemical analysis. The GUI plots spectral data based upon the user selection. So 3 graphs maximum, 1 graph minimum. Before plotting the data, the program checks certain tags to see if the data on file is not up to the standards determined on site. The user is warned and can continue with processing the data or skip that data type. I used a questdlg() that has 2 buttons 'yes' and 'no'.
   The program runs in order FCI, RCI, SWIR. So if a user selects FCI and SWIR for instance, gets a warning for FCI and chooses to skip that type, what command do I use to get the program to see if the SWIR checkbox is checked instead of having the program 'return'? Each acquisition type is seperated in the program because several other data processing functions need to be called for each type - so these warnings are not simply in the same if statement.
   I tried the following, but it simply returns for all cases:

if var_fci==1;
          if length(bad_fci)==3;
       buttons=questdlg({' The data on file shows that the pure component'
                 'you have selected was extremely fluorescent during'
                 'FCI acquisitions. Are you sure you want to proceed'
                 'with processing this data?'},'High Fluorescence Warning','Yes',...
                 'No','Info','No');
             switch buttons
                 case 'Yes'
                 case 'No'
                      if checkit_rci==1; %rci check box
                      elseif checkit_swir==1; %swir check box
                      else
                       msgbox('Please uncheck FCI box to continue.') %no other checkbox
                         return
                     end
  
    As always, thanks for your help MATLAB community
    Maxx

Subject: Tricky if statement

From: Sean

Date: 12 Aug, 2010 13:49:05

Message: 2 of 5

"machatsk " <chatskom@chemimage.com> wrote in message <i40tr8$3js$1@fred.mathworks.com>...
> Hello all,
> I have a GUI with 3 checkboxes that represent data types for chemical analysis. The GUI plots spectral data based upon the user selection. So 3 graphs maximum, 1 graph minimum. Before plotting the data, the program checks certain tags to see if the data on file is not up to the standards determined on site. The user is warned and can continue with processing the data or skip that data type. I used a questdlg() that has 2 buttons 'yes' and 'no'.
> The program runs in order FCI, RCI, SWIR. So if a user selects FCI and SWIR for instance, gets a warning for FCI and chooses to skip that type, what command do I use to get the program to see if the SWIR checkbox is checked instead of having the program 'return'? Each acquisition type is seperated in the program because several other data processing functions need to be called for each type - so these warnings are not simply in the same if statement.
> I tried the following, but it simply returns for all cases:
>
> if var_fci==1;
> if length(bad_fci)==3;
> buttons=questdlg({' The data on file shows that the pure component'
> 'you have selected was extremely fluorescent during'
> 'FCI acquisitions. Are you sure you want to proceed'
> 'with processing this data?'},'High Fluorescence Warning','Yes',...
> 'No','Info','No');
> switch buttons
> case 'Yes'
> case 'No'
> if checkit_rci==1; %rci check box
> elseif checkit_swir==1; %swir check box
> else
> msgbox('Please uncheck FCI box to continue.') %no other checkbox
> return
> end
>
> As always, thanks for your help MATLAB community
> Maxx


get(handles.my_checkbox,'Value');

Subject: Tricky if statement

From: machatsk

Date: 12 Aug, 2010 14:06:23

Message: 3 of 5

"Sean " <sean.dewolski@nospamplease.umit.maine.edu>
> get(handles.my_checkbox,'Value');

    This works and gives the correct value, but it just continues with the data processing steps below it. I guess my real problem is where the commands are in the code, but is there any way to skip those steps and continue reading code further in the program? I really do not want to put all of the data processing code with the 'case' for the questdlg()...
      Thank you for your swift reply
      Maxx

Subject: Tricky if statement

From: Sean

Date: 12 Aug, 2010 14:26:05

Message: 4 of 5

"machatsk " <chatskom@chemimage.com> wrote in message <i40v4u$144$1@fred.mathworks.com>...
> "Sean " <sean.dewolski@nospamplease.umit.maine.edu>
> > get(handles.my_checkbox,'Value');
>
> This works and gives the correct value, but it just continues with the data processing steps below it. I guess my real problem is where the commands are in the code, but is there any way to skip those steps and continue reading code further in the program? I really do not want to put all of the data processing code with the 'case' for the questdlg()...
> Thank you for your swift reply
> Maxx

I don't completely understand what you're saying, but I think I can give you a hint.
Have different functions do do different things. E.g. if the box is checked and it's okay it runs function everything_ok() else it runs function are_you_sure(). Don't do everything in one place; instead break it down into very localized 2-3 line functions that do exactly what you want for that case.

Subject: Tricky if statement

From: machatsk

Date: 12 Aug, 2010 14:32:09

Message: 5 of 5

"Sean " <sean.dewolski@nospamplease.umit.maine.edu>
> I don't completely understand what you're saying, but I think I can give you a hint.
> Have different functions do do different things. E.g. if the box is checked and it's okay it runs function everything_ok() else it runs function are_you_sure(). Don't do everything in one place; instead break it down into very localized 2-3 line functions that do exactly what you want for that case.

   Yeah thats what I started doing. Thanks for the help sir.
              Maxx

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us