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

23 Ansichten (letzte 30 Tage)
Maryam
Maryam am 19 Sep. 2017
Kommentiert: Walter Roberson am 19 Sep. 2017
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.

Antworten (1)

KSSV
KSSV am 19 Sep. 2017
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.

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by