Flip the frequency band.
Flip the freqencies of the time domain signal stored in X, so that the DC becomes the Nyquist frequency and the Nyquist frequency becomes the DC. (mirror all frequencies around FS/4) The routine is very fast and can also be used for streaming. X.length must be even.
Example 1
The sampling frequency is 256 Hz. A tone has a frequency 6Hz. After flipping the frequencies, the tone has a frequency of: FS/2 - 6 = 122Hz.
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit;
procedure TForm1.Button1Click(Sender: TObject);
var b,c,Response1, Response2: Vector;
begin
b := Sin(Ramp(256,0,2*Pi*6/256));
c.Copy(b);
BandFlip(b);
DrawIt([c,b],['Original signal','Flipped signal']);
FrequencyResponse(c,nil,Response1,1,True);
FrequencyResponse(b,nil,Response2,1,True);
DrawIt([Response1,Response2],['Spectrum: original signal','Spectrum: flipped signal']);
end;
#include "MtxVecCPP.h" //MtxVecCPP.cpp must be included in the project
#include "MtxVecEdit.hpp"
#include "MtxVecTee.hpp"
#include "SignalUtils.hpp"
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Vector b,c, Response1, Response2;
b = Sin(Ramp(256,0,2.0*PI*6/256));
c->Copy(b);
BandFlip(b);
DrawIt(OPENARRAY(TVec*,(c,b)),OPENARRAY(AnsiString,("Original signal","Flipped signal")));
FrequencyResponse(c,NULL,Response1,1,true);
FrequencyResponse(b,NULL,Response2,1,true);
DrawIt(OPENARRAY(TVec*,(Response1,Response2)),OPENARRAY(AnsiString,("Spectrum: original signal","Spectrum: flipped signal")));
}
using Dew.Math;
using Dew.Math.Editors;
using Dew.Math.Units;
using Dew.Signal;
using Dew.Signal.Units;
using Dew.Math.Tee;
using Dew.Signal.Tee;
private void button1_Click(object sender, EventArgs e)
{
Vector b = MtxExpr.Sin(MtxExpr.Ramp(256,0,2*Math.PI*6/256));
Vector c = new Vector(b.Length);
Vector Response1 = new Vector(0);
Vector Response2 = new Vector(0);
c.Copy(b);
SignalUtils.BandFlip(b);
TeeChart.DrawIt(new TVec[2] {c,b}, new string[2] {"Original signal","Flipped signal"},"Band flipped time signal", false);
SignalUtils.FrequencyResponse(c, null, Response1, 1, true, TSignalWindowType.wtRectangular, 0);
SignalUtils.FrequencyResponse(b, null, Response2, 1, true, TSignalWindowType.wtRectangular, 0);
TeeChart.DrawIt(new TVec[2] {Response1,Response2}, new string[2] {"Spectrum: original signal","Spectrum: flipped signal"}, "Band flipped frequency spectrum", false);
}