Clear Filters
Clear Filters

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

1 view (last 30 days)
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 Comments
Geoff Hayes
Geoff Hayes on 4 Apr 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 on 5 Apr 2015
Edited: AFFY on 5 Apr 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?

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 5 Apr 2015
Edited: Geoff Hayes on 5 Apr 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 Comments
AFFY
AFFY on 5 Apr 2015
what could be used instead of the identifier 'filename' ?

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!