From: loli J on
Hi all,,

In matlab GUI ,
How can I say that if the user click a button "B" and the axes "X" is empty ( I mean there is no image displayed on the axes) , an error message is displayed ?


Thanks all =)
From: Matt Fig on



if ~any(cellfun(@(x) strcmp(x,'image'),get(findobj(gca),'type')))
error(...)
end
From: Walter Roberson on
Matt Fig wrote:

> if ~any(cellfun(@(x) strcmp(x,'image'),get(findobj(gca),'type')))
> error(...)
> end

Shorter:

if isempty(findall(gca, 'type', 'image'))
error(...)
end
From: loli J on
"Matt Fig" <spamanon(a)yahoo.com> wrote in message <hu0l14$2o4$1(a)fred.mathworks.com>...
>
>
>
> if ~any(cellfun(@(x) strcmp(x,'image'),get(findobj(gca),'type')))
> error(...)
> end


Thanks for ur reply
I got an error :'(

??? Error using ==> cellfun
Input #2 expected to be a cell array, was char instead.

Error in ==> second>pushbutton2_Callback at 197
if ~any(cellfun(@(axes1) strcmp(axes1,'image'),get(findobj(gca),'type')))


How can I deal with it
From: loli J on
Walter Roberson <roberson(a)hushmail.com> wrote in message <2TQMn.87684$0B5.8177(a)newsfe05.iad>...
> Matt Fig wrote:
>
> > if ~any(cellfun(@(x) strcmp(x,'image'),get(findobj(gca),'type')))
> > error(...)
> > end
>
> Shorter:
>
> if isempty(findall(gca, 'type', 'image'))
> error(...)
> end




Thanks it works =)

Thank u all