슬라이더 콜백은 해제 한 후에 실행되는 슬라이더 콜백입니다. 위의 코드에서 슬라이더 콜백의 축에 플롯하는 값을 업데이트해야합니다. 너는 사실 아주 가깝다. 나는 그 라인을 옮기는 것이 더 좋을 것이라고 생각한다. :
handles.a = get(handles.slider2,'Value');
plot(handles.SupAirTemp,handles.a*handles.OutAirTemp)
내부의 슬라이더 콜백은 원하는대로 할 것이다.
다음 코드를 살펴보면 축, 슬라이더 및 슬라이더의 현재 값이 표시된 편집 상자가있는 간단한 GUI를 생성 할 수 있습니다. min, max 및 step과 같은 슬라이더 속성을 설정하여 원하는 비헤이비어를 얻을 수 있습니다.
function GUI_slider
clc
clear
%// Create GUI controls
handles.figure = figure('Position',[100 100 500 500],'Units','Pixels');
handles.axes1 = axes('Units','Pixels','Position',[60,100,400,300]);
handles.Slider1 = uicontrol('Style','slider','Position',[60 20 400 50],'Min',0,'Max',1,'SliderStep',[.1 .1],'Callback',@SliderCallback);
handles.Edit1 = uicontrol('Style','Edit','Position',[250 450 100 20],'String','Update Me');
handles.Text1 = uicontrol('Style','Text','Position',[180 450 60 20],'String','Slider Value');
handles.xrange = 1:20; %// Use to generate dummy data to plot.
guidata(handles.figure,handles); %// Update the handles structure.
function SliderCallback(~,~) %// This is the slider callback, executed when you release the it or press the arrows at each extremity.
handles = guidata(gcf);
SliderValue = get(handles.Slider1,'Value');
set(handles.Edit1,'String',num2str(SliderValue));
plot(handles.xrange,SliderValue*rand(1,20),'Parent',handles.axes1);
end
end
희망 하시겠습니까?
다시 한번 고마워. 나는 그곳에 원래의 '줄거리'를 남겨 두어 시작시 비례 그래프를 그곳에 남겨 두었습니다. 그런 다음 원하는 축척의 그래프로 축을 다시로드합니다. – josh
대단히 기쁩니다! –
GUI를 사용할 때 GUI를 사용할 때 GUI 시작시'clc' '모두 지우기 ' 'close all'을 사용하여 메모리를 지울 필요가 있습니까? 나는 추측하고 있지만 최선의 판단을하고 그것이 전체적인 질문의 가치가 없다고 생각했습니다. – josh