bodemag.m 函數(shù),執(zhí)行很慢,個人認為是for 循環(huán)導致時間很長;
原代碼:
% 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 循環(huán)太慢了;