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

9/24/2023 Lab assessment 2

MATLAB

Hammad Arshad
210606
LAB ASSESSMENT 2

State Space Representation


Control Conical Form:
Code:
%lab assessment 2
%obtain State Space Representation
% Control Conical form
clc
clear all
% Step 1: Define the transfer function
num = [1 7 6];
den = [1 9 26 24];

sys = tf(num, den);

% Step 2: Convert to control canonical form state-space


representation
[A, B, C, D] = ssdata(canon(sys, 'companion'));

% Step 3: Display the A, B, C, and D matrices


disp('A = ');
disp(A);

disp('B = ');
disp(B);

disp('C = ');
disp(C);

disp('D = ');
disp(D);

Result:
conic
A =
0 0 -24
1 0 -26
0 1 -9

B =
1
0
0

pg. 1
LAB ASSESSMENT 2

C =
1 -2 -2

D =
0

Command window:

Phase Variable Form:


Code:
%lab assessment 2
%obtain State Space Representation
% Phase Variable form
clc
clear all
% Define the transfer function
numerator = [1, 7, 6];
denominator = [1, 9, 26, 24];

pg. 2
LAB ASSESSMENT 2

G = tf(numerator, denominator);

% Convert to phase variable (controllable canonical) form


sys_ccf = canon(G, 'companion');

% Extract A, B, C, and D matrices


[A, B, C, D] = ssdata(sys_ccf);

% Display the state-space representation


disp('State-Space Representation in Phase Variable Form:');
disp('A matrix:');
disp(A);
disp('B matrix:');
disp(B);
disp('C matrix:');
disp(C);
disp('D matrix:');
disp(D);

Result:
State-Space Representation in Phase Variable Form:
A matrix:
0 0 -24
1 0 -26
0 1 -9

B matrix:
1
0
0

C matrix:
1 -2 -2

D matrix:
0

Command window:

pg. 3
LAB ASSESSMENT 2

]
LTI Form:
Code:
%lab assessment 2
%obtain State Space Representation
% Phase Variable form
clc
clear all
% Define the transfer function
numerator = [1, 7, 6];
denominator = [1, 9, 26, 24];
G = tf(numerator, denominator);

% Convert to state-space representation


sys_ss = ss(G);

% Display the state-space representation


disp('State-Space Representation (LTI form):');
disp(sys_ss);

pg. 4
LAB ASSESSMENT 2

Result:
State-Space Representation (LTI form):
ss with properties:

A: [3x3 double]
B: [3x1 double]
C: [0.5000 0.8750 0.3750]
D: 0
E: []
Scaled: 0
StateName: {3x1 cell}
StatePath: {3x1 cell}
StateUnit: {3x1 cell}
InternalDelay: [0x1 double]
InputDelay: 0
OutputDelay: 0
InputName: {''}
InputUnit: {''}
InputGroup: [1x1 struct]
OutputName: {''}
OutputUnit: {''}
OutputGroup: [1x1 struct]
Notes: [0x1 string]
UserData: []
Name: ''
Ts: 0
TimeUnit: 'seconds'
SamplingGrid: [1x1 struct]

Command window:

pg. 5
LAB ASSESSMENT 2

pg. 6

You might also like