Extract plot statistics for a specific range
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all, hope you are well.
I have a very basic question regarding the Data Statistics tool.
I'm plotting several acoustic metrics (such as sharpness, fluctuation strength etc) and am able to import data files (.wav) and plot the data without any issues. I have also made use of the Data Statistics tool to calculate the mean and max of the plotted data.
What I'm trying to do now is extract the data statistics for a specific range of the data - for example, the mean sharpness between 2 and 4 seconds of the audio file.
I'm sure there is a way to do this with some code etc - but I was hoping there would be a way to do it interactivly within the plot - almost like a set of cursors which can be moved which set the start and end points?
Any help is gratefully recieved.
All the best,
Andy
0 Kommentare
Antworten (2)
Star Strider
am 15 Jul. 2023
I don’t have the Curve Fitting Toolbox, however looking at the documentation for the datastats function, one option would be:
Lv = x >= 2 & x <= 4; % Logical Vector
[xds,yds] = datastats(x(Lv),y(Lv))
That should give you the result you want.
Example —
x = linspace(0, 20, 250).';
y = sin(2*pi*x/10) .* cos(2*pi*x/5) + randn(size(x))/5;
figure
plot(x, y)
grid
[xds,yds] = datastats(x, y)
Lv = x >= 2 & x <= 4; % Logical Vector
[xds24,yds24] = datastats(x(Lv),y(Lv))
Make appropriate variable name changes to work with your data.
.
0 Kommentare
phenan08
am 15 Jul. 2023
Bearbeitet: phenan08
am 15 Jul. 2023
You can try data selection using ginput. Example below:
x = rand(100,1) ; % generation of fake data
y = rand(100,1) ; % generation of fake data
figure ;
plot(x,y,"o") ;
selection = ginput(2) ; % selection of the bounds in the plot
tf = x >= min(selection(:,1)) & x <= max(selection(:,1)) ; % test to check whether the data belong to the selected interval or not
figure ;
plot(x(tf),y(tf),"o") ; % plotting the selected data
Then you can make data statistics on the selected data x(tf) and y(tf).
0 Kommentare
Siehe auch
Kategorien
Mehr zu Measurements and Feature Extraction 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!