Info

この質問は閉じられています。 編集または回答するには再度開いてください。

cannot findobj() when running as an EXE application

1 回表示 (過去 30 日間)
E
E 2015 年 9 月 19 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi Guys,
I have this weird issue where when im running my application from the Matlab env. everything is working well. when i later on compile it into an EXE and run it, it doesn't work. debugging showed me that the problem is when calling findobj();. when running in Matlab it returns the handle to the object im looking for and when running as an EXE it doesnt. For reference, see attached 2 images. one taken from within matlab and the second from the cmd prompt when EXE was running.
Console output running code from Matlab:
console output running compiled code from windows:
Code used:
% resetAllCheckBoxes(h);
checkBoxHandle = findobj('Tag',['param_',num2str(checkBoxNum)]);
disp('CHECK BOX HANDLE:')
checkBoxHandle
input('Press entere to continue');
set(checkBoxHandle,'Value',1);
end
Any idea whats going on here?

回答 (1 件)

Image Analyst
Image Analyst 2015 年 9 月 19 日
Add this code
str = ['param_',num2str(checkBoxNum)]
fprintf('checkBoxNum = %f\nLooking for tag = %s', checkBoxNum, str);
Any difference in what you see between the compiled and development environment?
  2 件のコメント
E
E 2015 年 9 月 19 日
Hi, THanks. I changed the code to the below and now it is working. still cant say why it didnt work before...
resetAllCheckBoxes(h);
set(h.(strcat('param_',num2str(checkBoxNum))),'Value',1);
Image Analyst
Image Analyst 2015 年 9 月 19 日
You might want to investigate what ishandle() returns:
itsAValidHandle = ishandle(checkBoxHandle)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by