2014-05-15 3 views
0

라디오 버튼을 누르면 선을 추가하려는 imagesc로 2 차원 플롯 (hhh 핸들)을 작성하고 푸시 버튼을 놓으면 동일한 선을 제거합니다.matlab uicontrol radiobutton 문제

불확정 함수 또는 변수 'Hline'

Lokks 프로그램이 Hline 기억 할수 없어 라인 : 누름 버튼 라인을 누를

는 누름 버튼이 해제 될 경우,이 오차가, OK 도시 심지어 guidata로 업데이트되고있다. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 이 ABC의 범위에 존재하는

서면으로

If you define additional input arguments, then the values you pass to the callback must exist in the workspace when the end user triggers the callback.

, 함수는 (Hline의 가치를 전달합니다 : 여기

감사

함수 콜백의 documentation에서

function abc(x) 
% x is a m x n matrix 
hhh=imagesc(x) 

% now a pushbutton to put or remove a line in the above plot 

uicontrol('Style','radiobutton','String','put_remove_line',... 
    'units','normalized','pos', [tf_left 0 .1/2 1/25],'parent',hhh,'HandleVisibility','on', 'fontSize',6,'Callback',{@put_remove_line ,delta_f_line, hhh ,Hline}); 

end % end abc function 
%radiobutton callback function 

function put_remove_line(hObject,event,delta_f_line,hhh,Hline) 

     a=get(hObject,'Value'); 
     if a % if button is pressed a 
       axes(hhh) 
       xlimits=get(gca,'XLim'); 
       Hline.xxx=line(xlimits,[delta_f_line], 'LineStyle',':','LineWidth',2); 

     else 
      delete(Hline.xxx,) 
     end 
guidata(hObject,Hline) 
end 

답변

0

입니다 x) uicontrol()이 실행될 때. 정의되지 않았기 때문에 오류가 발생합니다. 따라서 Undefined function or variable 'Hline'. 문제를 해결하려면 put_remove_line()의 시작 부분에서 Hline을 검색하려면 기존 guidata 저장 방법을 사용하십시오. Hline 가정

guidata에 저장됩니다

function abc(x) 
% x is a m x n matrix 
hhh = figure 
hhh2 = imagesc(x) 

% now a pushbutton to put or remove a line in the above plot 

uicontrol('Style','radiobutton','String','put_remove_line',... 
    'units','normalized','pos', [tf_left 0 .1/2 1/25],'parent',hhh,'HandleVisibility','on', 'fontSize',6,'Callback',{@put_remove_line ,delta_f_line, hhh}); 

end % end abc function 
%radiobutton callback function 

function put_remove_line(hObject,event,delta_f_line,hhh) 

     Hline = guidata(hObject) 
     a=get(hObject,'Value'); 
     if a % if button is pressed a 
       axes(hhh) 
       xlimits=get(gca,'XLim'); 
       Hline.xxx=line(xlimits,[delta_f_line], 'LineStyle',':','LineWidth',2); 

     else 
      delete(Hline.xxx) 
     end 
guidata(hObject,Hline) 
end 

편집 : 난 그냥 당신의 코드에 대한 다른 것을 깨달았다. 당신이 Hline 오류를 해결하면 또 다른 오류를받을거야 : 당신이 아이를 가질 수없는 이미지로 HHH를 정의하고 있기 때문에

Error using uicontrol 
An object of class uicontrol, can not be a child of class image. 

이다. 오류를 해결하기 위해 코드를 수정했습니다.이 오류는 부모 창 개체로 제공되는 그림 창을 여는 것입니다.

+0

많은 분들께 감사드립니다. 당분간 최고의 솔루션이 아닌 것처럼 보이는 글로벌 xxx를 사용하고 있습니다 ... –