Error in resampling function
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Multirate Signal Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!