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 clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.