Arrays 基于Matlab的环路阵列

Arrays 基于Matlab的环路阵列,arrays,matlab,for-loop,Arrays,Matlab,For Loop,我已经编辑了它,并且认为这会起作用,但是我得到了错误 lowpassFIR错误(第6行) passEdge=100 调用时未指定输出参数“f”(可能还有其他参数) “/Users/sergiogonzalez-palavicini/Documents/MATLAB/lowpassFIR.m>lowpassFIR”。您可以使用arrayfun: function f = lowpassFIR(sample) %Calculates Finite Impulse Response low pass

我已经编辑了它,并且认为这会起作用,但是我得到了错误

lowpassFIR错误(第6行) passEdge=100

调用时未指定输出参数“f”(可能还有其他参数)
“/Users/sergiogonzalez-palavicini/Documents/MATLAB/lowpassFIR.m>lowpassFIR”。

您可以使用
arrayfun

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
它将函数作为第一个参数,数组作为第二个参数。
它返回另一个数组,并将函数应用于原始数组的每个元素。

不太清楚……请检查,这可能会有所帮助。这取决于函数,如果它是矢量化的,那么您只需执行
Y=f(rect)
。您可以发布实际的函数吗?如果OP希望每个输出存储在不同的数组(单元格)中,您必须使用
'UniformOutput',false
选项。现在应该更清楚了!
>>> function a = func(b)
> a = b*2;
> end
>>> arrayfun(@func,1:10)
ans =

    2    4    6    8   10   12   14   16   18   20

>>>