Timeseries data convergence test
조회 수: 16 (최근 30일)
이전 댓글 표시
Hello Sir/Madam,
I'm trying to do convergence test for measurement data(Velocity) that we got from laboratory. I measured for 300 sec with sampling frequency of 200 Hz that means I have 60000,so I have array of 60000x1 . I'm trying to do convergence test for mean,rms, of velocity, I want to plot mean vs set of bins.
I want to start with first 1000 points average, then first 2000 points, then 3000 points...like continue till overall mean.
I checked online, I found cumsum function, but Cumsum function calculates every other element.
Can someone guide me how to proceed with this problem?
Thank you so much for your help in advance,
댓글 수: 2
답변 (1개)
Arjun
2024년 11월 8일 8:40
I see that you have some velocity data and you want to find the running mean and rms values.
To do so you can use a “for” loop which will run from 1 to the number of bins. In each iteration of the “for” loop you can extract the current accumulated data then find mean and rms values and store them in respective arrays for visualization later.
Kindly refer to the code below for better understanding:
% Assume velocityData is your 60000x1 data array
velocityData = randn(60000, 1);
maxPoints = length(velocityData);
increment = 1000;
% Preallocate arrays to store mean and RMS values
means = zeros(maxPoints/increment, 1);
rmsValues = zeros(maxPoints/increment, 1);
bins = increment:increment:maxPoints;
% Calculate mean and RMS for each bin
for i = 1:length(bins)
currentData = velocityData(1:bins(i));
means(i) = mean(currentData);
rmsValues(i) = rms(currentData);
end
% Plot the mean convergence
figure;
subplot(2, 1, 1);
plot(bins, means, '-o');
xlabel('Number of Data Points');
ylabel('Mean Velocity');
title('Convergence of Mean Velocity');
% Plot the RMS convergence
subplot(2, 1, 2);
plot(bins, rmsValues, '-o');
xlabel('Number of Data Points');
ylabel('RMS Velocity');
title('Convergence of RMS Velocity');
Kindly refer to the documentation of “mean” and “rms” function:
- mean: https://www.mathworks.com/help/releases/R2022a/matlab/ref/mean.html
- rms: https://www.mathworks.com/help/releases/R2022a/matlab/ref/rms.html
I hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!