Home Function in matlab guide to check for invalid values
Reply: 0

Function in matlab guide to check for invalid values

user1308
1#
user1308 Published in June 19, 2018, 6:12 pm

I am writing a function for my Matlab guide programme. I want to apply a limit for 3 text boxes in guide from 0 to 1 and it should only be number. (if a user inputs values that are invalid an error box should generate).The problem is that I want to write one function for that instead of writing limit code in the call back of each text box. It is also not necessary for the user to enter all the values at once, rather the function should run when any of the three values are input by the user and generate feedback. The function that I have written is as follows but it is not working. (It is not necessary that all the three input are provided to a function that's why I used || between inputs)

function CheckMe(maxMBT || minMBT || mainMBT)

 max_MBT= str2double(get(hObject, 'String'));

if isnan(maxMBT)||maxMBT < 0|| maxMBT> 1

  errordlg('Invalid max value for MBT. Please enter values between 0 to 1');
set(max_MBT, 'String', 0);

if isnan(minMBT)||minMBT < 0|| minMBT> 1
    set(min_MBT, 'String', 0);
    errordlg('Invalid min value for MBT. Please enter values between 0 to 1');

if isnan(mainMBT)||mainMBT < 0 || mainMBT >1
    set(edtMBT, 'String', 0);
    errordlg('Invalid value of MBT. Enter values between 0 to 1');

end
end
 end
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.337179 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO