필터 지우기
필터 지우기

Making a Gui with nested functions. My handle structure disappears after moving to different functions in the code.

조회 수: 1 (최근 30일)
I'm making a Gui without using Guide (I felt like it gave a lot of cloggy code) and I am having trouble keeping my handle structure in the code. I currently don't have any idea why it happens.
My code's basic structure is as follows.
function streakgui
h.fig= figure('position', [num num num num]);
%put button locations
h.browsebut= uicontrol...(its a pushbutton)
set(h.browsebut, 'Callback', {@browsedhf, h});
%other push button)
h.findpeaks= uicontrol(...
h.thresh= uicontrol('style', 'edit', 'position', [num num num num], 'String', 'Intensity Thres');
Other edittext box
h.minarea...
%callback functions
function h=findpeaks(hObject, eventdata, h)
h.thres=get(h.thresh,'String');
end
end
What happens next doesn't really matter but at this point some of my originial h fields go away and I don't know why. I've tried looking at it in debugging mode and h.fig and h.findpeaks are still there but the edit text boxes are gone from h when it is trying to pull the data. I'm not sure if I somehow deleted h or what is going. Any advice or tips would be apprieciated!

채택된 답변

Image Analyst
Image Analyst 2016년 6월 27일
findpeaks() is a built in function of the Signal Processing toolbox. That might be the problem. Use a different name for your custom function.
  댓글 수: 3
Image Analyst
Image Analyst 2016년 6월 27일
The solution can be found in this link.
Find out where the fields of h disappear and tell us what line caused that.
Aaron Greenbaum
Aaron Greenbaum 2016년 6월 28일
I ended up making h a global variable in my functions and solved the problem. Thanks for the debugging video, I saved it for reference.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by