How to select a part of a graph and have the data saved in a variable?
15 次查看(过去 30 天)
显示 更早的评论
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!