The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Simulators >> Circuit Simulators >> Ocean Code for using table function in the calculator
https://designers-guide.org/forum/YaBB.pl?num=1228854029

Message started by misfits on Dec 9th, 2008, 12:20pm

Title: Ocean Code for using table function in the calculator
Post by misfits on Dec 9th, 2008, 12:20pm

Hello all. I wish to plot piecewise linear graphs on the waveform window. I would like to read the points in from a text file. I can do this manually through the calculator table function. Can someone point me to the documentation which shows how to use this function within Ocean? Or failing that, provide the commands needed?

Thanks.

Title: Re: Ocean Code for using table function in the calculator
Post by pancho_hideboo on Dec 10th, 2008, 1:27am


misfits wrote on Dec 9th, 2008, 12:20pm:
Can someone point me to the documentation which shows how to use this function within Ocean?

As far as I know, there is no Skill function for table read.
But there is fscanf() function in Skill.
So you can create original functions to read table.

The following is simple example.

procedure( read1Plot( fileName, label )
 let( ( fp, x, y1, lx, ly1, xvec, yvec1, w1 )
       fp = infile( fileName )
       lx = nil
       ly1 = nil
       while( fscanf( fp, "%s %s", x, y1 ) == 2
              lx  = append( lx,  list( aelNumber(x) ) )
              ly1 = append( ly1, list( aelNumber(y1) ) )
       )

       xvec  = drCreateVec( 'double lx )
       yvec1 = drCreateVec( 'double ly1 )
       w1 = drCreateWaveform( xvec, yvec1 )

       plot(w1, ?expr list(label))

       close( fp )
 ) ; let end
) ; procedure end

Title: Re: Ocean Code for using table function in the calculator
Post by misfits on Dec 10th, 2008, 5:35am

This is perfect! I failed to realize it was possible to create waveforms on the window with the drCreateWaveform function.
Thanks so much for "drawing" my attention to it!

Title: Re: Ocean Code for using table function in the calculator
Post by pancho_hideboo on Dec 16th, 2008, 11:08pm

This is self followup.


pancho_hideboo wrote on Dec 10th, 2008, 1:27am:
As far as I know, there is no Skill function for table read.

Currently getAsciiWave() function is available for this purpose.

getAsciiWave( t_filename x_xColumn x_yColumn [x_xskip] [x_yskip])
=> o_wave / nil

Reads in an Ascii file of data and generates a waveform object from the
specified data. The X-axis data must be real numbers. The Y-axis data can be
real or complex values. Complex values are represented as (real imag) or
complex(real imag). This function skips blank lines and comment lines.
Comments are defined as lines beginning with a semicolon.

Title: Re: Ocean Code for using table function in the calculator
Post by Geoffrey_Coram on Dec 17th, 2008, 10:11am


pancho_hideboo wrote on Dec 16th, 2008, 11:08pm:
This is self followup.


pancho_hideboo wrote on Dec 10th, 2008, 1:27am:
As far as I know, there is no Skill function for table read.

Currently getAsciiWave() function is available for this purpose.


There is readTable (and writeTable), but it does appear that getAsciiWave() is really what you wanted.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.