-1
function f = 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);


rectPos = rectN/2;
rectNeg = (rectPos*-1);


%For the Vector Array
%rect = rectNeg:rectPos;

deltaSum= passEdge + (transWidth/2);
deltaF2= deltaSum/Fs;

for i = [rectPos:rectNeg]

   %iterate through each value and plug into function in for loop
   %each output of the function will be stored into another array
f= 2*i;
end





end

我已经对其进行了编辑,并认为这会起作用,但我收到了错误...

lowpassFIR 错误(第 6 行) passEdge = 100;

在调用“/Users/sergiogonzalez-palavicini/Documents/MATLAB/lowpassFIR.m>lowpassFIR”期间未分配输出参数“f”(可能还有其他参数)。

4

1 回答 1

1

您可以使用arrayfun

>>> function a = func(b)
> a = b*2;
> end
>>> arrayfun(@func,1:10)
ans =

    2    4    6    8   10   12   14   16   18   20

>>>

它将一个函数作为第一个参数,将一个数组作为第二个参数。
它返回另一个数组,函数应用于原始数组的每个元素。
文档

于 2013-06-24T05:23:05.170 回答