Decimated table exporting same size as original
Show older comments
I am trying to decimate a data file that was recorded at 100Hz and the original size of the file is ~6.16GB. I decimated the data by a factor of 2 (to reduce the sample rate to 50Hz), which seems successful:
However, when exported, the size isn't even 1GB less than the original file:

Is my decimation working correctly? Code below.
%%%% Loop to decimate 3 columns (out of 17 total columns)
s = size(data_XYZ);
r = 2;
n = ceil(s(1)/r);
data_XYZ_50 = zeros(n,s(2));
for k = 1:s(2)
data_XYZ_50(:,k) = decimate(data_XYZ(:,k),r);
end
%%%% Extracing every other line from the columns.
data_50 = data(1:2:end,:);
%%%% Replacing the 3 original columns with the decimated data
data_50{:,3} = data_XYZ_50(:,1);
data_50{:,4} = data_XYZ_50(:,2);
data_50{:,5} = data_XYZ_50(:,3);
save_directory = 'G:\path';
table_path = fullfile(save_directory, 'table.csv');
writetable(data_50,table_path)
8 Comments
Taylor, I thnk here's what's happening:
t = table([1;2;3],[1;2;3])
t{4:6,2} = [4;5;6]
But
t = table([1;2;3],[1;2;3])
t{4:6,:} = [4 4;5 5;6 6]
Taylor Azizeh
on 18 Jul 2023
Peter Perkins
on 28 Jul 2023
"data_50 = data([3;4;5], [3;4;5]) % This creates a table that is 3x3"
It doesn't. That's your problem.
Taylor Azizeh
on 21 Aug 2023
"However, when exported, the size isn't even 1GB less than the original file"
You are comparing apples with oranges:
- your original file is an Excel proprietary file of some kind, which either stores compressed text data (e.g. XLSX ultimately uses ZIP) or uses binary to store numeric data (e.g. XLS)
- your new file is an uncompressed text file.
Different file types containing completely different data, so any comparison between them is basically pointless.
"Is my decimation working correctly?"
Probably, but comparing diffrerent data stored in compressed and uncompressed data files is not going to tell you if your decimation if working or not (hint: check the variable size in MATLAB).
"I'm just confused how data can be 83745100x17 table and data_50 can be 1/2 that (41872550x17 table) and not export at 1/2 of the size of the original file?"
Here is the explanation:

Taylor Azizeh
on 21 Aug 2023
Edited: Taylor Azizeh
on 21 Aug 2023
Stephen23
on 21 Aug 2023
"However, when I exported it as a CSV (this is the format I need), it is the same size."
A CSV file is just an uncompressed text file, why should it be any different?
"Are you saying that if my variable size in MATLAB looks decimated: 83745100/2 = 41872550, then it should be working?"
You could check it yourself: take the first few values, calculate by hand what you expect the "decimated" values to be.
Taylor Azizeh
on 21 Aug 2023
Answers (0)
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!