getFile/ imread cooperation error

Hello, so i have this little app i made, and right now im working on exceptions.
And my problem is, probably not that complicated, but i cant find solution. So to start, I let user pick a file, the jpg ( its stated in my work that database pics are all jpg blah blah ), next thing is imread. As long as user chooses the file, everything is great, but, i need an exception ( probably an if end) that would cover the Cancel option, because if user wont pick a file, imread goes crazy.
IMG = uigetfile('*.jpg');
IMG0=imread(IMG);
all im asking is, how to make an exception that would cover the Cancel option,
Thanks in advance <3

Respuestas (1)

Damian Pietron
Damian Pietron el 16 de Mzo. de 2019
ok that was way easier than i thought, and this worked perfectly fine.
IMG = uigetfile('*.jpg');
if IMG==0
return
end

1 comentario

if isnumeric(IMG); return; end
better style. Otherwise you are comparing the vector of characters to 0 and relying on the fact that if IMG==0 is treated the same as if all(IMG==0)

Iniciar sesión para comentar.

Categorías

Más información sobre Large Files and Big Data en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Mzo. de 2019

Comentada:

el 16 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by