Calculate the intersection (and difference) of two 1D text waves
aclight
//**
// Calculates the intersection of two 1D text waves.
//
// @param wave1
// First 1D text wave.
// @param wave2
// Second 1D text wave.
// @param resultWave
// A text wave where the result will be stored. This wave will be overwritten if it already contains
// any data.
// @param rejectWave
// [OPTIONAL] A text wave where all values that are in the shorter of wave1 and wave 2 but
// not in the longer are stored. Providing this parameter allows you to determine both which
// values are present in both waves and which are not. NOTE: rejectWave will NOT contain
// values that are present in the longer of the two waves but not in the shorter.
//*
Function CalculateTextWaveIntersection(wave1, wave2, resultWave, [rejectWave])
WAVE/T wave1
WAVE/T wave2
WAVE/T resultWave
WAVE/T rejectWave
Variable processRejects
if (ParamIsDefault(rejectWave))
processRejects = 0
else
processRejects = 1
endif
Variable wave1Rows = DimSize(wave1, 0)
Variable wave2Rows = DimSize(wave2, 0)
Variable longRows, shortRows
if (wave1Rows > wave2Rows)
Duplicate/O/T wave1, longWave
WAVE/T shortWave = wave2
longRows = wave1Rows
shortRows = wave2Rows
else
Duplicate/O/T wave2, longWave
WAVE/T shortWave = wave1
longRows = wave2Rows
shortRows = wave1Rows
endif
// Sort values in longWave
Sort longWave, longWave
Redimension/N=(0) resultWave
Variable n, numOutRows, longWaveRow, rejectRows
For (n=0; n<shortRows; n+=1)
FindValue/TEXT=shortWave[n]/TXOP=4 longWave
longWaveRow = V_Value
if ((longWaveRow) >= 0 && cmpstr(longWave[longWaveRow], shortWave[n]) == 0)
Redimension/N=(numOutRows + 1) resultWave
resultWave[numOutRows] = shortWave[n]
numOutRows += 1
elseif (processRejects)
rejectRows = DimSize(rejectWave, 0)
Redimension/N=(rejectRows + 1) rejectWave
rejectWave[rejectRows] = shortWave[n]
endif
EndFor
KillWaves/Z longWave
End
// Calculates the intersection of two 1D text waves.
//
// @param wave1
// First 1D text wave.
// @param wave2
// Second 1D text wave.
// @param resultWave
// A text wave where the result will be stored. This wave will be overwritten if it already contains
// any data.
// @param rejectWave
// [OPTIONAL] A text wave where all values that are in the shorter of wave1 and wave 2 but
// not in the longer are stored. Providing this parameter allows you to determine both which
// values are present in both waves and which are not. NOTE: rejectWave will NOT contain
// values that are present in the longer of the two waves but not in the shorter.
//*
Function CalculateTextWaveIntersection(wave1, wave2, resultWave, [rejectWave])
WAVE/T wave1
WAVE/T wave2
WAVE/T resultWave
WAVE/T rejectWave
Variable processRejects
if (ParamIsDefault(rejectWave))
processRejects = 0
else
processRejects = 1
endif
Variable wave1Rows = DimSize(wave1, 0)
Variable wave2Rows = DimSize(wave2, 0)
Variable longRows, shortRows
if (wave1Rows > wave2Rows)
Duplicate/O/T wave1, longWave
WAVE/T shortWave = wave2
longRows = wave1Rows
shortRows = wave2Rows
else
Duplicate/O/T wave2, longWave
WAVE/T shortWave = wave1
longRows = wave2Rows
shortRows = wave1Rows
endif
// Sort values in longWave
Sort longWave, longWave
Redimension/N=(0) resultWave
Variable n, numOutRows, longWaveRow, rejectRows
For (n=0; n<shortRows; n+=1)
FindValue/TEXT=shortWave[n]/TXOP=4 longWave
longWaveRow = V_Value
if ((longWaveRow) >= 0 && cmpstr(longWave[longWaveRow], shortWave[n]) == 0)
Redimension/N=(numOutRows + 1) resultWave
resultWave[numOutRows] = shortWave[n]
numOutRows += 1
elseif (processRejects)
rejectRows = DimSize(rejectWave, 0)
Redimension/N=(rejectRows + 1) rejectWave
rejectWave[rejectRows] = shortWave[n]
endif
EndFor
KillWaves/Z longWave
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More