Saving the zoom in plot

조회 수: 5 (최근 30일)
JA
JA 2016년 7월 20일
편집: JA 2016년 7월 20일
I have a GUI where i plot my signal, I import the signal with 'getappdata', apply filter to the signal and plot it.
function slider1_Callback(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
%get slider value for frequency
sliderValue = get(handles.slider1,'Value');
%set editbox value
set(handles.edit1,'String',sliderValue)
%get the signal to be filtered
sig = getappdata(0,'signal');
%instantiate the filter class
f = ltiFilter.PT1();
%set the frequcny
f.fc = sliderValue;
%apply filter
for i = 1: length(sig)
updated(i).filter = f.eval(sig(i).signal,sig(i).signal(1));
end
for i = 1:length(sig)
plot(sig(i).time,sig(i).signal,sig(i).time,updated(i).filter)
hold on
end
hold off
legend('raw','filt');
This code works correctly, but the only problem is when i re-slide, it re-plots so i lose then zoom. and have to re zoom. So i retrieve the and restore the current zoom like this:
% retrieve the current zoom
tmp_xlim = get(handles.axes1, 'xlim');
tmp_ylim = get(handles.axes1, 'ylim');
for i = 1:length(sig)
plot(sig(i).time,sig(i).signal,sig(i).time,updated(i).filter);
hold on
end
hold off
legend('raw','filt');
% restore the zoom properties
set(handles.axes1, 'xlim', tmp_xlim);
set(handles.axes1, 'ylim', tmp_ylim);
Now the graph doesn't plot at all. Have no idea why. Any suggestions will be helpful.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by