frequencyOffset
Description
applies the specified frequency offset to the input signal y
= frequencyOffset(x
,samplerate
,offset
)x
.
Examples
Generate a rectangular 16-point quadrature amplitude modulated (16-QAM) signal by modulating a vector of input data.
M = 16; data = (0:M-1)'; x = qammod(data,M);
Specify the signal sample rate and the frequency offset to apply.
samplerate = 1; offset = 100e3;
Apply the frequency offset to the input signal.
y = frequencyOffset(x,samplerate,offset);
Define parameters to configure the signal and spectrum analyzer.
fc = 1e6; % Carrier frequency (Hz) fs = 4e6; % Sample rate (Hz) Nspf = 100e3; % Number of samples per frame freqSpan = 400e3; % Frequency span for spectrum computation (Hz)
Create sine wave and spectrum analyzer objects with the specified parameter values.
sinewave = dsp.SineWave(Amplitude=1, ... Frequency=fc, ... SampleRate=fs, ... SamplesPerFrame=Nspf, ... ComplexOutput=true); sascope = spectrumAnalyzer( ... SampleRate=fs, ... FrequencySpan="Span and center frequency", ... CenterFrequency=fc, ... Span=freqSpan, ... SpectrumType="Power density", ... SpectrumUnits="dBW/Hz", ... ShowLegend=true, ... ChannelNames=["Input sine wave","Frequency-offset sine wave"], ... YLimits=[-50 10]);
Generate a sine wave signal.
x = sinewave();
Apply a frequency offset of 100 kHz to the signal.
offset = 100e3; y = frequencyOffset(x,fs,offset);
Display the input and frequency-shifted signals by using the spectrum analyzer.
sascope(x,y)
Input Arguments
Input signal, specified as a column vector or matrix.
Data Types: double
| single
Complex Number Support: Yes
Sampling rate of the input signal in Hz, specified as a positive scalar.
Data Types: double
Frequency offset in Hz, specified as a scalar or row vector.
If
offset
is a scalar, the function applies the same frequency offset to each channel.If
offset
is a vector, then each element specifies the frequency offset that the function applies to the corresponding column (channel) of the input signal. The number of elements inoffset
must equal the number of columns inx
.
Data Types: double
Output Arguments
Output signal, returned as a vector or matrix with the same dimensions and data type
as x
. The number of columns in y
corresponds
to the number of channels.
Data Types: double
| single
Complex Number Support: Yes
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Version History
Introduced in R2022a
MATLAB Command
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.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)