bodemag.m 函数,执行很慢,个人认为是for 循环导致时间很长;
原代码:
% for i = 1:length(omega)
% s = 1i * omega(i);
% H_num = polyval(num, s);
% H_den = polyval(den, s);
% H = H_num / H_den;
% magnitude(i) = 20 * log10(abs(H));
% end
可以修改为:
omega= 1:1:length(omega)
s = 1i .* omega;
H_num = polyval(num, s);
H_den = polyval(den, s);
H = H_num ./ H_den;
magnitude = 20 * log10(abs(H));
采用向量的形式计算速度会更快一点;for 循环太慢了;