Create a Warning in GUI if statement

7 Ansichten (letzte 30 Tage)
Sean
Sean am 17 Mai 2016
Beantwortet: Image Analyst am 17 Mai 2016
Hi,
I'm trying to create a warning in a GUI I wrote, if all values in a column of a cell array are greater than a number display a warning.
I've tried this but it isn't working
if c{:,2}>10
warndlg('string')
end
Any help is appreciated.
  1 Kommentar
dpb
dpb am 17 Mai 2016
What does "not working" mean, precisely? The construct appears it should be fine. Is the array _c_ in context to the callback, perhaps?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Walter Roberson
Walter Roberson am 17 Mai 2016
if all(cellfun(@(C) ~isempty(C) && isnumeric(C) && all(C(:) > 10), c(:,2) ))
warndlg('string')
end
I have made the assumption here that items that are not numeric should not be counted as being > 10, and the additional assumption that empty cells are not to be counted as being > 10. However, in either of those cases, since the cell would not be counted as having a value greater than 10, it would not be true that all the values in the cell array column were greater than 10 so no warning would be produced.
I did not assume that the entries in the cell array were all the same size or the same number of dimensions.

Image Analyst
Image Analyst am 17 Mai 2016
Tip: to have it wait for you to click OK, wrap the warndlg() in a uiwait():
uiwait(warndlg('Hey, you really messed up!!!')); % Wait for user to click OK.
Otherwise it goes blasting ahead without waiting.

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by