I am stumped by the behaviour of evalfr vs freqresp in the control systems toolbox. They claim to give the same results, but when their arguments are purely real there is a (large!) discrepancy. I am inclined to believe the results from evalfr; for all sane transfer functions a real value of s should result in a real value of the transfer function.
With the following code:
G = tf([1],[1 1]); wc = 3+1e-10*1i; [evalfr(G,wc);freqresp(G,wc)]
Both give the answer 0.2500-0.0000i.
When the input is purely real, however:
G = tf([1],[1 1]);wc = 3; [evalfr(G,wc);freqresp(G,wc)]ans = 0.2500 + 0.0000i 0.1000 - 0.3000i
I'm using Matlab 2020a and I believe this behaviour has been around for a while; I came across an old code comment that said something like "don't use freqresp — evalfr gives proper results here". Fine for me, but harder to advise when teaching students…
Best Answer