bodemag.m 函數(shù),執(zhí)行很慢,個(gè)人認(rèn)為是for 循環(huán)導(dǎo)致時(shí)間很長;
原代碼:
% 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));
采用向量的形式計(jì)算速度會(huì)更快一點(diǎn);for 循環(huán)太慢了;