04

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

4.

write a Matlab program to determine the time domain


response of a second order system for step input and obtain
performance parameters and verify theoretically.

Theory:
Steps to Determine Time Domain Response and
Performance Parameters:
1. Define System Parameters:
• Set the values of ωn\omega_nωn and ζ\zetaζ for the second-order system.

2. Construct Transfer Function:


• Use MATLAB's tf function to define the transfer function G(s)G(s)G(s)
using the specified ωn\omega_nωn and ζ\zetaζ.

3. Generate Step Response:


• Use the step function in MATLAB to compute the step response of the
system over a specified time vector.

4. Calculate Performance Parameters:


• Peak Time: Time at which the response reaches its maximum value.
• Settling Time: Time required for the response to stay within a certain
percentage (typically 5%) of the final value.
• Overshoot: Maximum percentage by which the response exceeds the
final value.
• Rise Time: Time required for the response to rise from 10% to 90% of its
final value.

5. Compare with Theoretical Values:


• Calculate the theoretical values of peak time, settling time, overshoot, and
rise time based on the formulas derived from the system parameters
ωn\omega_nωn and ζ\zetaζ.
Program:
% Define system parameters

wn = 5; % Natural frequency (rad/s)

zeta = 0.7; % Damping ratio

% Construct transfer function

numerator = wn^2;

denominator = [1 2*zeta*wn wn^2];

sys = tf(numerator, denominator);

% Step response analysis

t = 0:0.01:10; % Time vector

step_response = step(sys, t);

% Calculate performance parameters

% Peak time

[peak_value, peak_index] = max(step_response);

peak_time = t(peak_index);

% Settling time (within 5% of final value)

final_value = step_response(end);

tolerance = 0.05 * final_value;

settling_start_index = find(abs(step_response - final_value) < tolerance, 1, 'first');

settling_time = t(settling_start_index);
% Overshoot and rise time

overshoot = (peak_value - final_value) / final_value * 100;

rise_time = t(find(step_response >= 0.9 * final_value, 1, 'first')) - t(find(step_response >= 0.1


* final_value, 1, 'first'));

% Theoretical values

wn_theoretical = sqrt(numerator);

zeta_theoretical = zeta;

% Display results

fprintf('Performance Parameters:\n');

fprintf('Peak Time (sec): %.2f\n', peak_time);

fprintf('Settling Time (sec): %.2f\n', settling_time);

fprintf('Overshoot (%%): %.2f\n', overshoot);

fprintf('Rise Time (sec): %.2f\n', rise_time);

fprintf('\nTheoretical Values:\n');

fprintf('Natural Frequency (rad/s): %.2f\n', wn_theoretical);

fprintf('Damping Ratio: %.2f\n', zeta_theoretical);

% Plot step response

figure;

plot(t, step_response, 'LineWidth', 1.5);

grid on;

xlabel('Time (sec)');

ylabel('Amplitude');
title('Step Response of Second Order System');

Explanation:
• System Parameters:
o wn and zeta are defined to specify the natural frequency and
damping ratio of the second-order system.
• Transfer Function:
o sys is created using the tf function to represent the transfer
function of the system.
• Step Response Analysis:
o The step function computes the step response of the system over
time t.
• Performance Parameters Calculation:
o Peak time, settling time, overshoot, and rise time are calculated
based on the step response data.
• Theoretical Values:
o Theoretical values of natural frequency and damping ratio are
computed.
• Plotting:
o Displays the step response graphically for visual inspection.

Graph:
Conclusion:
This MATLAB program allows for the comprehensive analysis of a second-
order system's time-domain response to a step input. It calculates and compares
performance parameters such as peak time, settling time, overshoot, and rise
time with their theoretical expectations based on system parameters. This
analysis is crucial for understanding and evaluating the behavior of second-
order systems in control and signal processing applications. Adjust the system
parameters (wn and zeta) according to your specific system to see how the
response changes.

You might also like