0% found this document useful (0 votes)
3 views2 pages

pr02 Dinsis

Uploaded by

Zahran Ghifari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

pr02 Dinsis

Uploaded by

Zahran Ghifari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

% MATLAB code to plot the impulse response of a first-order system

% Define the parameter T (time constant)


T = 1; % You can adjust this value as needed

% Define the time vector from 0 to 5*T for the plot


t = linspace(0, 5*T, 500);

% Define the impulse response function c(t) in the time domain


c_t = (1/T) * exp(-t/T);

% Plot the response


figure;
plot(t, c_t, 'LineWidth', 2); % Plot with thicker line for visibility
hold on;

% Annotate the plot with labels and title


xlabel('t'); % Label for time axis
ylabel('c(t)'); % Label for response axis
title('Impulse Response of First-Order System'); % Title of the plot

% Add annotation at the peak with LaTeX interpreter


text(T, 1/T, '$c(t) = \frac{1}{T}e^{-t/T}$', 'FontSize', 12, ...
'HorizontalAlignment', 'left', 'Interpreter', 'latex');

% Customize the axes limits


xlim([0 5*T]); % Set x-axis limit from 0 to 5*T
ylim([0 1.1/T]); % Set y-axis limit from 0 to slightly above 1/T

% Add y-axis label at 1/T


text(0, 1/T, '$\frac{1}{T}$', 'HorizontalAlignment', 'right', ...
'VerticalAlignment', 'middle', 'Interpreter', 'latex', 'FontSize', 12);

% Set custom x-tick labels as multiples of T


xticks(0:T:5*T); % Define ticks at 0, T, 2T, 3T, 4T, 5T
xticklabels({'0', 'T', '2T', '3T', '4T', '5T'}); % Label them as multiples of T

% Plot grid
grid on;

% Add a legend with LaTeX interpreter


legend('$c(t) = \frac{1}{T}e^{-t/T}$', 'Location', 'northeast', 'Interpreter',
'latex');

1
% Explain:
% This code defines the impulse response for a first-order system with
% transfer function C(s)/R(s) = 1/(Ts+1). It plots c(t) as a function of
% time t, showing the exponential decay characteristic of a first-order
% system's impulse response. The annotation and markers highlight
% key points in the response.

You might also like