Error in resampling function
Afficher commentaires plus anciens
Hi I am still new to MATLAB but have been instructed to upsample some torque data using a function:
function res_signal_out = resample_zeroshift(res_signal_in, length_resample)
% Zero the signal start
tmp_signal = res_signal_in - res_signal_in(1);
% Flip and append so that signal ends at zero
tmp_signal = [tmp_signal; flipud(tmp_signal)];
% Resample linearly
res_tmp_signal = resample(tmp_signal, length_resample*2, length(tmp_signal));
% Take first half of resampled signal and add offset that was removed
res_signal_out = res_tmp_signal(1:length_resample) + res_signal_in(1);
end
I am calling the function with the script:
clear; clc;
% import data file
textTable = readtable(fullfile(pwd,'Torque08forResampling.TXT'));
% convert data to array
textArray = table2array(textTable);
% iterate through the 7 columns of data in the file and resample using function resample_zeroshift
for i = 1:width(textArray)
textResults(:,i) = resample_zeroshift(textArray(:,i),93001);
end
This function works for a torque file that has only 2993 rows of data, being upsampled to 6000... however when I use the same code for a torque file which is 46517 rows long, upsampling to 93001, the error that I am getting is:
Error using upfirdn>validateinput (line 129)
The product of the downsample factor Q and the upsample factor P must be less than 2^31.
Error in upfirdn (line 81)
[p,q] = validateinput(x,h,varargin);
Error in resample>uniformResample (line 478)
yVec = upfirdn(x,h,p,q);
Error in resample (line 217)
uniformResample(xIn, isDimValSet, Dim, dimIn, numericArgs{:});
Error in resample_zeroshift (line 7)
res_tmp_signal = resample(tmp_signal, length_resample*2, length(tmp_signal));
Would appreciate any help!!
Thanks
PS I am using MATLAB R2021a
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Multirate Signal Processing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!