How to select a part of a graph and have the data saved in a variable?

조회 수: 8 (최근 30일)
Maryam
Maryam 2017년 9월 19일
댓글: Walter Roberson 2017년 9월 19일
Hello all, I have time history of measured data from some experiments (accelerations vs time). The experiments were a couple of hours. I want to do the following: Plot the whole time history of data, select a portion of it and have the data from that portion saved in a variable so that I can use it in my code to perform a FFT (fast fourier transform) on it. Does anyone know how I can have the selected data saved in a variable:
In other words:
  • %data is the time history of the data
  • Step 1- plot=data(:,1)
  • Step 2- select some parts of data graphically (maybe using brush function?)
  • Step 3- A= seleted data from the graph
  • Step 4- FFT(A)
Thank you very much in advance.

답변 (1개)

KSSV
KSSV 2017년 9월 19일
You may plot and select the data of your interest as below:
N = 100 ;
x = (1:N)' ;
y = rand(N,1) ;
plot(x,y) ;
hold on
pts = ginput(2) ;
%%pick the data which was picked via ginput
idx = knnsearch([x y],pts) ;
xi = x(idx(1):idx(2)) ;
yi = y(idx(1):idx(2)) ;
plot(xi,yi,'.r') ;
legend('data','data picked')
For Fourier Transform Analysis read about fft. It is a straight forward task.

카테고리

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