Average the every 40 rows from csv file until finish and save the data in new csv files
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I am completely stuck here and do not know how to proceed. Basically, I am reading the sensor data from the excel which have a 40 repetition every second. I want to take a average of 40 repetition and save into separate file, data is for like 20 mins. Below is the code I am trying but can't think from an hour how to proceed further.
a = readmatrix('firsttest_2_try.csv');
x = a (:,1);
y = a (:,3);
counter = 0
for i = 1 : length(x)
counter = counter+i;
end
any help would be great
댓글 수: 0
채택된 답변
Star Strider
2021년 10월 4일
I have no idea what you want to do.
If you want to take the mean of the 1 second blocks (and you have the Signal Ptocessing Toolbox), use the buffer function separately on ‘x’ and ‘y’., then take the mean of the resulting matrix across dimension #1 (columns).
Calculate the number of samples as:
NrSamples = Fs*sec;
where ‘Fs’ is the sampling frequency and ‘sec’ is the number of seconds.
.
댓글 수: 2
Star Strider
2021년 10월 4일
muhammad choudhry’s Answer became this Comment —
I just want to take the average of rows in the excel file by 40 until the number of rows finish and save into df file.
Star Strider
2021년 10월 4일
Use the buffer function. If you so not have the Signal Processing Toolbox, use this simple emulation of it —
x = randi(9, 1, 11);
r = 4;
Q1 = buffer(x,r) % Original
Q2 = bufr(x,r) % Emulation
function M = bufr(s,r)
% s = Signal Vector
% r = Desired number of rows
M = zeros(r,ceil(numel(s)/r));
M(1:numel(s)) = s;
end
.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!