Zooming in on a graph / partitioning a data set

6 views (last 30 days)
Hello, I have a fairly large data set which has large sinusoids made up of smaller sinusoids. I need to find absolute peaks (i.e. the larger sinusoids). I tried various smoothing mechanisms and nested findpeaks loops to no avail.
So I'm just thinking about biting the bullet and using ginput, clicking on them. However, the data set is large enough and compact enough that even full screen I cannot click on points to a decent precision. (It's over 60000 ms and I don't want to lose specificity). With ginput in effect, I cannot zoom in on the graph.
I also considered using fplot but as the data set is not a function, this does not work.
My questions: Is there a way to partition the graph so that I could have many graphs of a certain length and identify absolute maximums (similar to fplot but workable for data sets)?
and
How would I zoom in on parts of the graph if I am not to partition it?
Thanks a lot!
  2 Comments
Tom
Tom on 30 May 2012
If the signal is not too noisy you could use a FFT to get the amplitude of the large sinusoids.
For the graphs, do you mean splitting the data and plotting each set on a separate set of axes?
Robert
Robert on 30 May 2012
I've come to the conclusion that it's pretty noisy. In various attempts, I tried:
-FFT
-multiple "smooth" iterations (aka re-smooth the already smoothed one), and then a double -findpeaks loop which compares peaks with those before and those after
an iteration using "max" over various intervals: sometimes the method above does not work due to the fact that there were some tiny peaks on the climbing or descending side of the larger sinusoid which rose up above their neighbors. However, there are various sections on the graph that are simply flat for several ms and ruin this method.
I am not extremely handy with any of these methods so maybe with fine-tuning I could accomplish what I want, but I am getting to the point where I just want results, even if I have a slightly more painstaking method of getting them (there are probably only about 200 peaks to deal with).
And yes, I mean splitting the data and plotting each set on a separate set of axes; possibly 30 figures each housing 2000 ms, for example.

Sign in to comment.

Accepted Answer

Tom
Tom on 30 May 2012
You could use ginput two or three times: the first ones to adjust the x and y limits around the point selected, and the last one to pick the point of interest. Otherwise, you could just plot in a loop- a quick (shoddy) example is below: click on a region, then press return to move to the next plot. This particular code doesn't snap to the data, but you can implement something like that easily (round to the nearest data point, for example)
Data=randn(3500,1);
t=1:length(Data);
NoSamples=1000;
NoPlots=ceil(length(Data)/NoSamples);
for i=1:NoPlots
SampleRange=(i-1)*NoSamples +1:i*NoSamples; %range of data to be plotted
if max(SampleRange) > length(Data) %last set of data might have shorter length
SampleRange=(i-1)*NoSamples +1:length(Data);
end
plot(t(SampleRange),Data(SampleRange))
grid on
[x(i,1),y(i,1)] = ginput(1); %use ginput and save selection
pause %press enter to move to next plot
end
disp([x,y])
  1 Comment
Robert
Robert on 30 May 2012
Very reasonable and seems it would work for my purposes. Thanks a lot for the help!

Sign in to comment.

More Answers (0)

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!