Average the every 40 rows from csv file until finish and save the data in new csv files
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
muhammad choudhry
le 4 Oct 2021
Commenté : Star Strider
le 4 Oct 2021
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 commentaires
Réponse acceptée
Star Strider
le 4 Oct 2021
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 commentaires
Star Strider
le 4 Oct 2021
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
le 4 Oct 2021
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
.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!