Extract plot statistics for a specific range
조회 수: 11 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Star Strider
2023년 7월 15일
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
phenan08
2023년 7월 15일
편집: phenan08
2023년 7월 15일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Measurements and Feature Extraction에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!