フィルターのクリア

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

1 回表示 (過去 30 日間)
AFFY
AFFY 2015 年 4 月 4 日
コメント済み: AFFY 2015 年 4 月 5 日
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 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 4 月 4 日
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 2015 年 4 月 5 日
編集済み: AFFY 2015 年 4 月 5 日
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?

サインインしてコメントする。

回答 (1 件)

Geoff Hayes
Geoff Hayes 2015 年 4 月 5 日
編集済み: Geoff Hayes 2015 年 4 月 5 日
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 件のコメント
AFFY
AFFY 2015 年 4 月 5 日
what could be used instead of the identifier 'filename' ?
AFFY
AFFY 2015 年 4 月 5 日
it worked. thanks a lot for your help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by