function [n, status] = nma_verify_valid_non_negative_numeric(str, h, msg) %verifies string represents non negative number status = 0; [n, status] = str2num(str); if not(status) uiwait(errordlg(sprintf('non - numeric value for %s',msg),... 'Bad Input', 'modal')); uicontrol(h); return end if n < 0 uiwait(errordlg(sprintf('%s can not be negative',msg),... 'Bad Input', 'modal')); uicontrol(h); status = 0; return end status = 1; end