Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
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;
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
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
Join the community of 500,000 technology professionals and ask your questions.