y = upsample(x,n)
increases the sample rate of x by inserting
n – 1 zeros between samples. If x is a
matrix, the function treats each column as a separate sequence.
Generate a 101-second sine waveform with a fundamental frequency of 0.01 Hz and a space of 5 seconds between consecutive samples.
ts = 5;
tx = (1:ts:101)';
x = sin(2*pi*0.01*tx);
Upsample the signal using an upsampling factor of 3. Compare the original and upsampled signals. To produce the upsampled signal, the upsample function inserts two zeros between sine samples.
n = 3;
ty = (1:ts/n:ts*numel(x))';
y = upsample(x,n);
plot(tx,x,"o",ty,y,".")
legend(["Original""Upsampled"])
Upsample the signal using an upsampling factor of 3 and a phase offset of 1. Compare the original and upsampled signals. Because of the specified phase offset, the first sample of the original signal matches with the second sample on the upsampled signal.
p = 1;
ty = (1:ts/n:ts*numel(x))';
y = upsample(x,n,p);
plot(ts/n*p+tx,x,"o",ty,y,".")
legend(["Original""Upsampled"])
Upsampled array, returned as a vector or matrix. y
has x × n samples.
Tip
To remove the imaging artifacts from the upsampled output
y, apply a lowpass filter to
y with cutoff normalized frequency of
pi/n rad/sample.
Alternatively, use the interp function.
The upsample function supports code generation for
graphical processing units (GPUs). You must have MATLAB®
Coder™ and GPU Coder™ to generate CUDA® code.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.