Borrar filtros
Borrar filtros

how to call functions saved in other m.file in gui?

1 visualización (últimos 30 días)
AFFY
AFFY el 4 de Abr. de 2015
Comentada: AFFY el 5 de Abr. de 2015
If we access functions that are not in-built in MATLAB but stored manually, it gives error in GUI. The same functions are running normally without GUI.
function recog_Callback(hObject, eventdata, handles)
I= getappdata(0,'I');
.
.
.
img1=(im2bw(I,0.9));
img2=(im2bw(r,0.9));
[mssim ssim_map] = ssim_index(img1, img2);
where ssim_index is a function stored in another m file. I am getting error Output argument "mssim" (and maybe others) not assigned during call to "D:\codes\ssim_index.m>ssim_index".
  2 comentarios
Geoff Hayes
Geoff Hayes el 4 de Abr. de 2015
AFFY - the error message suggests that there is something (perhaps) failing in your ssim_index function and so the outputs are not being assigned. Put a breakpoint at the line
[mssim ssim_map] = ssim_index(img1, img2);
and re-run your GUI and wait until the debugger pauses at this line. Check the inputs img1 and img2 - are they valid? Also verify that ssim_index function does in fact return two outputs. If it does, look at this function to see why it may exit before the outputs are set.
AFFY
AFFY el 5 de Abr. de 2015
Editada: AFFY el 5 de Abr. de 2015
from the breakpoint i got to know that img1 is empty.
but i wrote
img1=(im2bw(I,0.9)); in the same function and the variable I ws assigned an image in the another pushbutton callbacK. I also wrote setappdata(0,'filename',I); so as to use that I variable in a different function. but it seems that variable I value din't get assigned. how to do that?

Iniciar sesión para comentar.

Respuestas (1)

Geoff Hayes
Geoff Hayes el 5 de Abr. de 2015
Editada: Geoff Hayes el 5 de Abr. de 2015
AFFY - you mention that img1 where
img1=(im2bw(I,0.9));
and that I was assigned an image in another pushbutton callback as
setappdata(0,'filename',I);
Note that setappdata (as used above) sets the image I to be uniquely identified by 'filename'. And so if you wish to retrieve this image in another callback, you would need to do
I = getappdata(0,'filename');
rather than the
I = getappdata(0,'I');
as 'I' is not a valid identifier for any data saved to the graphics object identified by zero. Change your getappdata call to
I = getappdata(0,'filename');
and step through the code once again. You should be able to get an image (though you may want to consider renaming the identifier from 'filename' to something else that indicates that this is an image).
  2 comentarios
AFFY
AFFY el 5 de Abr. de 2015
what could be used instead of the identifier 'filename' ?
AFFY
AFFY el 5 de Abr. de 2015
it worked. thanks a lot for your help

Iniciar sesión para comentar.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by