frequencyOffset
Description
applies the specified frequency offset to the input signal y
= frequencyOffset(x
,samplerate
,offset
)x
.
Examples
Apply Frequency Offset to Rectangular 16-QAM Signal
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);
Apply Frequency Offset to Sine Wave
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", ... SpectralAverages=10, ... 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
x
— Input signal
column vector | matrix
Input signal, specified as a column vector or matrix.
Data Types: double
| single
Complex Number Support: Yes
samplerate
— Sampling rate
positive scalar
Sampling rate of the input signal in Hz, specified as a positive scalar.
Data Types: double
offset
— Frequency offset
scalar | row vector
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
y
— Output signal
column vector | matrix
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
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.
Americas
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)