Possible problem with example in intdec documentation
Reported by Federico Miyara
BUG DESCRIPTION:
----------------
The example provided in the documentation for the resampling function intdec:
Fs1 = 10000; // initial sampling frequency
Fs2 = 14000; // targeted resampling frequency
t1 = (0:1/Fs1:5)';
t2 = (0:1/Fs2:5)';
F0 = 2; // Signal frequency
u1 = sin(2*%pi*F0*t1);
u2 = sin(2*%pi*F0*t2); // Direct sampling at targeted frequency (as reference)
u2b = intdec(u1, Fs2/Fs1); // Resampled signal
clf
plot(t2,u2,"b", t2,(u2b-u2)*1000, "r");
legend("Direct highly sampled u2","(resampled_u1 - u2) x 1000","in_upper_left");
may present a problem. There is no guarantee that length(t2) = length(u2b), so t2 should be defined from the real length of the resampled signal instead of the theoretical length (which is only approximate).
ERROR LOG:
----------
Inconsistent row/column dimensions.
HOW TO REPRODUCE THE BUG:
-------------------------
Take
Fs1 = 10000;
Fs2 = 9807;
instead of the original data
OTHER INFORMATION:
------------------
Even if in the original example the problem does not show, it stimulates a buggy programming approach.
Moreover, the documentation should warn about the rather impredictable size of the resampled signal.
A clear example of this is that the length of
intdec(intdec(x, p/q), q/p)
is, in general, different from the length of x