Search code examples
matlab

How to solve this question by writing code in MATLAB?


Consider the control system shown in Figure. Determine the gain K and time constant T of the controller Gc(s) such that the closed-loop poles are located at s = -2+-Questionj2.

I have solved the question on pen-paper but dont know jhow to do it in MATLAB and write the code for it.Solution


Solution

  • The easiest way is to use the symbolic toolbox:

    syms k t s
    
    %Write denominators:
    Dd = s^2 + 4*s+8;
    Dk = s^2 + (2+k*t)*s +  k;
    
    %get coeffs
    c1 = coeffs(Dd)
    c2 = coeffs(Dk,'s')
    
    %solve
    solve(c1==c2)
    

    Use doc <command> to check the documentation of the commands used to get familiar with the toolbox.

    Edit: Also, check these commands: poly(r),numden(A),simplify(expr), fliplr(v). With these, you can even create a program to create the denominator instead of manually writing it. And keep in mind, you can write a complex number as: c = 5+3i.