function ButterworthLPF(TimeHistory:OleVariant; SamplingFrequency, CutOffFrequency:real; FilterOrder:byte=8):OleVariant;
//This works for 1-column input
var fs, fc, odr : OleVariant;
begin;
fs := SamplingFrequency;
fc := CutOffFrequency;
odr := FilterOrder div 2;
result := bwLPF(TimeHistory, fs, fc, odr);
end;
function NewButterworthLPF(TimeHistory:OleVariant; SamplingFrequency, CutOffFrequency:real; FilterOrder:byte=8):OleVariant;
//This does NOT work for 3-column input
var fs, fc, odr : OleVariant;
i, j : integer;
vt : TVarType;
begin;
vt := VarType(TimeHistory);
if (vt and varVariant = varVariant) then
for i := 1 to VarArrayHighBound(TimeHistory, 1) do
result[i] := NewButterworthLPF(TimeHistory[i], SamplingFrequency, CutOffFrequency, FilterOrder)
else
fs := SamplingFrequency;
fc := CutOffFrequency;
odr := FilterOrder div 2;
result := bwLPF(TimeHistory, fs, fc, odr);
end;
function NewButterworthLPF(TimeHistory : Variant; SamplingFrequency, CutOffFrequency:real; FilterOrder:byte=8) : Variant;
var
fs, fc, odr : OleVariant;
i, j : integer;
vt : TVarType;
begin
vt := VarType(TimeHistory);
if (vt and varVariant = varVariant) and (TVarData(TimeHistory[VarArrayLowBound(TimeHistory, 1)]).VType and VarVariant = varVariant) then
begin
Result := VarArrayCreate([0, VarArrayHighBound(TimeHistory, 1)], varVariant);
for i := 0 to VarArrayHighBound(TimeHistory, 1) do
begin
Result[i] := NewButterworthLPF(TimeHistory[i], SamplingFrequency, CutOffFrequency, FilterOrder)
end;
end
else
begin
fs := SamplingFrequency;
fc := CutOffFrequency;
odr := FilterOrder div 2;
result := bwLPF(TimeHistory, fs, fc, odr);
end;
end;
function NewButterworthLPF(TimeHistory : Variant; SamplingFrequency, CutOffFrequency:real; FilterOrder:byte=8) : Variant;
//This does seem to work for both single column, and multi column inputs.
var fs, fc, odr : OleVariant;
i, j : integer;
vt : TVarType;
begin;
vt := VarType(TimeHistory);
if (vt and varVariant = varVariant) then
begin;
Result := VarArrayCreate([0, VarArrayHighBound(TimeHistory, 1)], varVariant);
for i := 1 to VarArrayHighBound(TimeHistory, 1) do
result[i] := NewButterworthLPF(TimeHistory[i], SamplingFrequency, CutOffFrequency, FilterOrder);
end
else
begin;
fs := SamplingFrequency;
fc := CutOffFrequency;
odr := FilterOrder div 2;
result := bwLPF(TimeHistory, fs, fc, odr);
end;
end;
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
IdTCPClient and IdTCPServer exchanging data on desktops and not Android | 11 | 115 | |
RESTRequest Parameter | 4 | 31 | |
How to Convert a Quote to an Order in SalesForce | 2 | 43 | |
printf performancy | 11 | 43 |
Join the community of 500,000 technology professionals and ask your questions.