필터 지우기
필터 지우기

Creating a slider when real time plotting

조회 수: 6 (최근 30일)
isra
isra 2017년 1월 5일
답변: khan 2017년 1월 5일
Hello I'm plotting sensor measurements in real time, after a while the data gets so cramped and hard to read. I'd like to create a slider that will enable me to scroll through the date (x axis) in a fixed window (say 10 secs), zooming it in to allow clearer display. Is that possible with matlab? I tried the following link which displays a slider for a sine wave with fixed length, I just don't know how to make it work with real time plotting.
regards I.H

답변 (3개)

khan
khan 2017년 1월 5일
to my understanding i think you need a sliding window of 10 sec sliding window mean, if yes, then you can create sliding window for taking average of the data on each 10 seconds.
  댓글 수: 1
isra
isra 2017년 1월 5일
편집: isra 2017년 1월 5일
I want it to zoom in to display a portion of the figure, not to do any calculations. like a magnifying lenses.

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


khan
khan 2017년 1월 5일
set(data,'XLim',[st end]);
can help your problem.
  댓글 수: 1
isra
isra 2017년 1월 5일
편집: isra 2017년 1월 5일
Thank you very much for replying
where should I put this? in my original code that plots in real time or in the function file?
here is my current code without using the slider fucntion from the link:
%%setting up connectio with arduino
clear all;
a = arduino;
%%setting up plots and variables
time = [0]; v1 = [0]; v2 = [0];
subplot(211) ;
h = plot(time, v1, 'r-'); % Save handle to the line
title('Channel 1');
ylabel('Amplitude(V)'); axis ([0 inf 0 inf]);
subplot(212); h2= plot(time, v2, 'b-'); % Save handle to the line
title('Channel 2');axis ([0 inf 0 inf]);
ylabel('Amplitude(V)');
tic; %%starting stopwatch
%%Reading sensors
while (1)
voltage1 = readVoltage(a,'A0');
voltage2 = readVoltage(a,'A1');
%%updating x and y values for each channel
time = [time,toc]; % Append to vectors
v1 = [v1,voltage1];
v2 = [v2,voltage2];
%%updating plots
set(h, 'xdata', time, 'ydata', v1); % Update plot
set(h2, 'xdata', time, 'ydata', v2); % Update plot
drawnow;
end

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


khan
khan 2017년 1월 5일
ax = findobj(gcf,'type','axes','tag',''); set(ax,'XLim',[250 300]); %here instead of [250 300] you can specify your own time window/s
after plotting your data, just specify the time interval you want zoom in to and run these two lines. it will zoom in the already plotted data to the time specified region.

카테고리

Help CenterFile Exchange에서 Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by