Decimation function needs a double precision vector
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Taylor Azizeh
le 13 Juil 2023
Commenté : Taylor Azizeh
le 13 Juil 2023
I am trying to decimate some data that was recorded at 100Hz down to 50Hz. So far, I extracted the three columns to decimate and tried:
data_X = data(:,[3])
It's a massive file, so here is the ouput preview, so you can get an idea of what is going into the next piece of code.

Then, I am trying to run the decimate function using...
data_X_50 = decimate(data_X,2);
resulting in this error:
.I am very new to coding in MatLab and this is my first time posting a question here, so I really appreciate any help.
0 commentaires
Réponse acceptée
Dyuman Joshi
le 13 Juil 2023
Modifié(e) : Dyuman Joshi
le 13 Juil 2023
Using parentheses () on table returns a sub-table.
x = primes(20)';
y = (1:numel(x))';
T = table(x,y)
%When you use (), Output is returned as a table
T(:,1)
Use curly braces
T{:,1}
or dot indexing to access the content of the table in the stored format -
T.(1)
This assumes that the initial data is of double format. If it is of single format (which seems to be the only other option with the data given), convert it to double.
6 commentaires
Dyuman Joshi
le 13 Juil 2023
data_XYZ = data{:,[3 4 5]};
%Get the size of the array
s = size(data_XYZ);
%Decimation factor
r = 2;
%The decimated signal is shortened by a factor of r, so the length of
%output will be
n = ceil(s(1)/r);
Reference for the length - decimate
%Preallocating the final output
out = zeros(n,s(2));
%looping through the columns of the data
for k=1:s(2)
out(:,k) = decimate(data_XYZ(:,k),r);
end
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing 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!