Clear Filters
Clear Filters

Plot the time-domain response of a swept frequency signal

2 views (last 30 days)
Hello, I am currently trying to plot the response of a swept-frequncy cosinusoidal signal and lsim this swept-frequency signal using a transfer function.
Ie; suppose I generate the following input swept frequency signal of the form:
y = chirp(t,f0,t1,f1)
And if i generate a continuous time transfer function of the format:
sys = tf(numerator,denominator)
Can i use lsim and plot the output of all signals within the swept-band?
output=lsim(sys,y,t)
The end goal of mine is to have all of these overlayed signals' eye diagrams be plotted.
I want to then do:
eyediagram(output, %numsamples/trace);
Is this good framework to follow or do you all suggest something else that may work better?
Regards

Accepted Answer

Paras Gupta
Paras Gupta on 21 Aug 2023
Hi Rohan,
I understand that you want to plot time-domain response of multiple signals using eye diagrams in a swept frequency band. The approach followed by you is valid and can be run for multiple signals by:
  • Using for loops
  • Passing a signals matrix as input to the ‘lsim’ function
An example code that uses for loops is given below:
% Define the swept-band parameters
t = 0:0.01:10; % Time vector
f0 = 1; % Initial frequency
t1 = 10; % End time
f1 = 10; % Final frequency
numFreqs = 10; % Number of frequencies in the swept-band
% Generate the swept-band signals
frequencies = linspace(f0, f1, numFreqs); % Frequency range
signals = zeros(length(t), numFreqs); % Matrix to store the signals
for i = 1:numFreqs
signals(:, i) = chirp(t, f0, t1, frequencies(i));
end
% Define the transfer functions for each input channel
numerator = 1; % Numerator coefficients
denominator = [1, 1, 1]; % Denominator coefficients
sys = tf(numerator, denominator); % Define the transfer function for the current signal
% Simulate the response for each signal in the swept-band
outputs = zeros(length(t), numFreqs); % Matrix to store the outputs
for i = 1:numFreqs
outputs(:, i) = lsim(sys, signals(:, i), t);
end
% Plot the output of all signals within the swept-band
figure;
hold on;
for i = 1:numFreqs
plot(t, outputs(:, i));
end
hold off;
xlabel('Time');
ylabel('Output Signal');
title('Response of the System for Swept-Band Signals');
% Generate the eye diagram for a specific signal
signalIndex = 3; % Index of the signal to generate the eye diagram
numsamples = 100; % Number of samples per trace
eyediagram(outputs(:, signalIndex), numsamples);
xlabel('Time');
ylabel('Amplitude');
title('Eye Diagram of a Swept-Band Signal');
More information on using the signals matrix as an argument to the ‘lsim’ function can be found in the documentation below under section 'Plot Simulated Response of MIMO System'.
Hope this helps.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!