Search code examples
matlabfrequencytoolkit

Matlab solve with complex expressions


I have the following Matlab expression (transfer function):

H(w) = 0.1/(1 - 0.9exp(-jw))

where w is a symbolic variable (omega).

I'm trying to solve the following expression for w:

|H(w)| == 1/sqrt(2)

Solving this by hand I believe the answer should be 0.105, but I cannot get this answer. I've tried adding assumptions for w is real and w>0

I've tried the following commands:

solve(abs(H)==1/sqrt(2),w)

and

solve(H^2==1/2,w)  

with no luck. Any assistance would be greatly appreciated.

Thanks!


Solution

  • First of all, the assumption for w to be real is important, in the complex domain, the equation has an infinite number of solutions. For real w there are two, since H(-w) = conj(H(w)) and therefore abs(H(-w))=H(w) (actually more than two since H(w) is 2pi-periodic, see the edit at the end of the reply).

    Here is where it gets funny. If you only state w to be real, it works fine:

    >> syms w real;
    >> H = 0.1/(1-0.9*exp(-j*w));
    >> solve(abs(H)==1/sqrt(2),w)
    
      ans =
    
        -atan(359^(1/2)/179)
    
    >> eval(ans)
    
      ans = 
    
        -0.1055
    

    From the above we kind of know that +0.1055 is also a solution.

    However, if we additionally ask w to be positive (e.g., assumeAlso(w>=0)), something strange happens and we get a result with two parameters, an integer k (giving 2 pi k multiples) and a scalar z with some conditions on it (at least one of the conditions on z does give the correct value of 0.1055 but I really wonder about the 2 pi k multiples). I'm not sure why this happens. Maybe someone else can clarify.

    edit: As pointed out by Jonathan, the 2 pi k multiples are actually expected since exp(-j*(w+2*pi)) = exp(-j*w) and hence H(w) is 2pi-periodic. It's still odd that Matlab returns one solution when we assume w real and multiple solutions when we additionally assume w non-negative.