Matlab won't find complex magnitude?

4 views (last 30 days)
ioannis gregos
ioannis gregos on 22 Feb 2019
Edited: ioannis gregos on 22 Feb 2019
I am trying to find the complex magnitude of this transfer function for a low pass filter
syms H w R C f
H = 1/(sqrt(-1)*w*C*R+1)
H = simplify(abs(H))
Creates
How do I get:
I have tried
H = rewrite(H, 'sqrt')
And have gotten literally the same thing. I am starting to think such a simple thing is not possible. The goal is to evaluate this transfer function at the cutoff frequency (-3db)
w = solve(H == sqrt(1/2), w)
But I cannot do this unless I have the complex magnitude. Yes I can do this by hand but I have another script which is supposed to evaluate a large equation and doing it by hand would take ages. Thank you.

Answers (1)

ioannis gregos
ioannis gregos on 22 Feb 2019
Edited: ioannis gregos on 22 Feb 2019
Figured it out. You must set assumptions of the variables, whether they are real or complex. Matlab doesn't know how to interpret your symbolic variables so it doesn't.
use the syms 'set' command like so:
syms w R C f real
syms H
H = 1/(sqrt(-1)*w*C*R+1)
H = simplify(abs(H))
Should work
If you want to get it in the form sqrt(x^2 + (iy)^2) do:
syms w R C f real
syms H
H = 1/(sqrt(-1)*w*C*R+1)
H = rewrite(abs(H), 'sqrt')

Categories

Find more on Symbolic Math Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!