I wouldn't call it a fitted line, but here's the code nevertheless. Was quite easy to throw together (it does bear some similarities with abBestFit, but it's considerably simpler as it doesn't need to do any linear regression). /* abFirstLastLine.il Author A.D.Beckett Group Custom IC (UK), Cadence Design Systems Ltd. Language SKILL Date May 16, 2018 Modified By Construct a line between first and last points in waveform. Not a best fit - just a simple line consisting of just the first and last points. Includes function template so this can be added to the calculator with the "fx" button in the calculator function panel. *************************************************** SCCS Info: @(#) abFirstLastLine.il 05/16/18.22:55:10 1.1 */ /********************************************************************* * * * (abFirstLastLine wave) * * * * Output a waveform which just contains the first and last points of * * the input waveform. * * * *********************************************************************/ ( defun abFirstLastLine (wave) ( cond (( drIsWaveform wave) ( let (xVec yVec newXVec newYVec len newWave) ( setq xVec ( drGetWaveformXVec wave)) ( setq yVec ( drGetWaveformYVec wave)) ( setq len ( drVectorLength xVec)) ( setq newXVec ( drCreateVec 'double 2)) ( setq newYVec ( drCreateVec 'double 2)) ( drAddElem newXVec ( drGetElem xVec 0)) ( drAddElem newXVec ( drGetElem xVec ( sub1 len))) ( drAddElem newYVec ( drGetElem yVec 0)) ( drAddElem newYVec ( drGetElem yVec ( sub1 len))) ;----------------------------------------------------------------- ; Sort out attributes for new waveform to match input ;----------------------------------------------------------------- ( putpropq newXVec ( getq xVec units) units) ( putpropq newXVec ( getq xVec name) name) ( putpropq newYVec ( getq yVec units) units) ( putpropq newYVec ( getq yVec name) name) ( setq newWave ( drCreateWaveform newXVec newYVec)) (famSetExpr newWave `(abFirstLastLine ,(famGetExpr wave))) newWave ) ) ((famIsFamily wave) (famMap 'abFirstLastLine wave) ) (t ( error "abFirstLastLine: cannot handle %L\n" wave) ) ) ) ; ;;;;;;;;;;;;;;;;;;;;;;;;;; GUI builder information ;;;;;;;;;;;;;;;;;;;;;;;;;;; ocnmRegGUIBuilder( '( nil function abFirstLastLine name abFirstLastLine description "Create line between first and last points" category ( "Custom Functions" ) analysis ( nil general ( nil args (wave ) signals ( nil wave ( nil prompt "Waveform" tooltip "Waveform" ) ) params( nil ) inputrange t ) ) outputs(result) ) )
↧