Average the every 40 rows from csv file until finish and save the data in new csv files
1 回表示 (過去 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!