-1
function [h,w,y,graph] = lowpassFIR(sample)
%Calculates Finite Impulse Response low pass filter coefficient
%using the windowing methods as well
passEdge = 100;
StopbandAtt = 20;
passbandRip =.05;
transWidth = 10;
Fs = sample;
%Step One: select number of coefficients%
deltaF = transWidth/Fs;
%Normalize for each window
rectN = round(0.9/deltaF);
hannN = round(3.1/deltaF);
hammN = round(3.3/deltaF);
blackN = round(5.5/deltaF);
rectN = 1:rectN
%rectPos = round(rectN/2);
%rectNeg = round((rectPos*-1));
%For the Vector Array
%rect = rectNeg:rectPos;
deltaSum= passEdge + (transWidth/2);
deltaF2= deltaSum/Fs;
h=zeros(size(1:rectN(end)));
w=zeros(size(1:rectN(end)));
y=zeros(size(1:rectN(end)));
graph = plot(y)
for i = 1:rectN(end)
%iterate through each value and plug into function in for loop
%each output of the function will be stored into another array
h(i) = 2*deltaF2*(sin(i*2*pi*deltaF2))/(2*i*pi*deltaF2);
w(i) = 0.5 + 0.5*cos(2*pi*i/rectN(end));
y(i) = h(i)*w(i);
graph(i) = y(i);
end
從代碼中可以看出,我試圖從圖表中得到圖表結果....但是當它輸出時,我在命令窗口中獲取了這些值,但是該圖顯示了一條直線@零。如何在這裏自動縮放y軸?我應該如何自動設置這個Matlab圖?
如果我刪除了循環......它只輸出一個值,因爲它不會重複... – user2514874
@ user2514874你如何消除環路?你使用我答案中的代碼嗎? – Schorsch