Asked by HAITHAM AL SATAI
on 27 May 2019

I'm trying to solve the system below, Could you check my work if it is correct or not?

close all;

clear all;

clc

%% 1) Set a requirement for step response, like settling time, overshoot

%and static error of output.

A=[0,1,0,0;0,-42.44,212.24,0;0,0,0,1;0,0,0,-42.44];

B=[0;106.12;0;78.6];

C=[1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1];

D=0;

sys = ss(A, B, C, D)

t=0:0.1:10;

figure;

step(sys,t,'r')

%The parameters including overshoot, settling time and static error.

S = stepinfo(sys)

%% 2)Select the desired poles according to your requirements. If possible,

%calculate the feedback matrix K to place the poles to the desired poles.

eig(sys)

% Now we check the stability

rank(ctrb(sys))

%The desired poles

P = [-1; -2; -3; -3.2850]

K = place(A,B,P)

%% 3) Simulate step response of the feedback system and calculate the parameters

%%including overshoot, settling time and static error. If the system does not satisfy the

%%requirement, go back to step 2).

Acl = A-B*K

syscl = ss(Acl,B,C,D)

figure;

step(syscl,'g')

%The parameters including overshoot, settling time.

S = stepinfo(syscl)

title('Step response of feedback control system')

grid on

%% 4) Design state observer of the system. The magnitude of observer poles must be 2~5

%times of system poles. Select different observer poles and compare the performance

%of observers.

sys=ss(A,B,C,D)

eig(sys)

rank(obsv(sys))

% Observer pole placement at -10 and -9

% This observer will lead to a fast approximation of the states

L_T=place(A',C',[-10,-9,-8,-7])

L=L_T'

% Observer pole placement at -1 and -2

% This observer will lead to a slower approximation of the states

% L_anastrofos=place(a',c',[-1,-2])

% L=L_anastrofos'

% State observer Feedback

sys=ss(A,B,C,D)

eig(sys)

rank(obsv(sys))

rank(ctrb(sys))

K=place(A,B,[-5 -6 -7 -8])

Answer by Raj
on 28 May 2019

Edited by Raj
on 28 May 2019

Accepted Answer

Pretty good start!!

Now, please note that since you have mentioned that your doubt is in implementation, I have seen only your code.

I have not seen its exact correctness w.r.t the questionare that you have put.

1)" Set a requirement for step response, like settling time, overshoot and static error of output."- What you are doing is computing the step response of your system. Actually in addition to that, you have to set up some desired time domain step response critetia that your closed loop system (system+controller) should satisfy. Something like settling time should be 5 sec, overshoot should be less than 15% of peak value, settling error should be within 10% of final value etc.

2) rank(ctrb(sys)) will give you controllability of system not stability. eig(sys) will give you eigen values of system and if real part of eigen values are negative then system is stable or vice versa. Recommend giving a quick brush up on controllability and stability.

3) %The desired poles P = [-1; -2; -3; -3.2850] It will be good if you show how you arrived at these values.

4) Also in third step where you are simulating step response of the feedback system and calculating the parameters, you may have to go back and find different set of gains (k) if response is not meeting desired criteria set in s/n.1

Good Luck!!

HAITHAM AL SATAI
on 28 May 2019

@Raj I got your idea Sir. But in my system when I apply this

%The parameters including overshoot, settling time and static error.

S = stepinfo(sys)

I got nothing :

S =

4×1 struct array with fields:

RiseTime

SettlingTime

SettlingMin

SettlingMax

Overshoot

Undershoot

Peak

PeakTime

How I extract these information ?

Raj
on 28 May 2019

HAITHAM AL SATAI
on 28 May 2019

@Raj Thank you so much sir for your help

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Geoff Hayes (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/464214-could-you-check-this-implementaion-of-controller-and-observer-design#comment_709105

## HAITHAM AL SATAI (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/464214-could-you-check-this-implementaion-of-controller-and-observer-design#comment_709208

Sign in to comment.