Hi,
I needed a function that will resample waveform using points from another waveform.
So I wrote function below:
;Function to resample sourceWave by points from pointsWave
;sourceWave waveform to be resamled
;pointsWave from this waveform points taken to resample sourceWave
procedure( resampleByWave(sourceWave pointsWave)
let( (xVec yVec wave yFactor numOfPoints thisX sweepVal i sweepName sweepValues currentSourceWave currentPointsWave sweepValType)
cond(
(drIsWaveform(sourceWave)
;printf("%L\n" sourceWave->??)
wave=drCreateEmptyWaveform()
xVec=drGetWaveformXVec(pointsWave);x vector created from pointsWave
numOfPoints=drVectorLength(xVec)
yVec=drCreateVec(drType(drGetWaveformYVec(sourceWave)) numOfPoints);empty y vector
for( i 0 sub1(numOfPoints);for each point from pointsWave
thisX=drGetElem(xVec i);x value
currentValue=value(sourceWave thisX );y value from sourceWave corresponding to x value from pointsWave
drAddElem(yVec currentValue);add y element
);for
drPutWaveformXVec(wave xVec)
drPutWaveformYVec(wave yVec)
wave~>leafSignalTypeName=sourceWave~>leafSignalTypeName
wave~>leafDataSet=sourceWave~>leafDataSet
wave~>leafAnalysisType=sourceWave~>leafAnalysisType
);drIsWaveform(sourceWave)
(famIsFamily(sourceWave)
sweepName=famGetSweepName(sourceWave)
sweepValues=famGetSweepValues(sourceWave)
sweepValType=type(car(sweepValues))
case(sweepValType
('fixnum wave=famCreateFamily(sweepName 'intlong))
('flonum wave=famCreateFamily(sweepName 'float))
('string wave=famCreateFamily(sweepName 'string))
(t error("resampleByWave: unable to understand type %L\n" sweepValType))
);case
foreach( sweepVal sweepValues
currentSourceWave=famValue(sourceWave sweepVal)
currentPointsWave=famValue(pointsWave sweepVal)
famAddValue(wave sweepVal resampleByWave(currentSourceWave currentPointsWave ))
);foreach
);famIsFamily(sourceWave)
(t
error("resampleByWave: invalid waveform %L\n" sourceWave)
);t
);cond
wave
);let
);proc
I am not sure about a case when input waveforms are family of plots. Is this part of the code correct?