The Designer's Guide Community
Forum
Welcome, Guest. Please Login or Register. Please follow the Forum guidelines.
May 1st, 2024, 3:48am
Pages: 1
Send Topic Print
Ocean Code for using table function in the calculator (Read 4634 times)
misfits
New Member
*
Offline



Posts: 2

Ocean Code for using table function in the calculator
Dec 09th, 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.
Back to top
 
 
View Profile   IP Logged
pancho_hideboo
Senior Fellow
******
Offline



Posts: 1424
Real Homeless
Re: Ocean Code for using table function in the calculator
Reply #1 - 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
Back to top
 
 
View Profile WWW Top+Secret Top+Secret   IP Logged
misfits
New Member
*
Offline



Posts: 2

Re: Ocean Code for using table function in the calculator
Reply #2 - 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!
Back to top
 
 
View Profile   IP Logged
pancho_hideboo
Senior Fellow
******
Offline



Posts: 1424
Real Homeless
Re: Ocean Code for using table function in the calculator
Reply #3 - 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.
Back to top
 
« Last Edit: Dec 17th, 2008, 7:02am by pancho_hideboo »  
View Profile WWW Top+Secret Top+Secret   IP Logged
Geoffrey_Coram
Senior Fellow
******
Offline



Posts: 1998
Massachusetts, USA
Re: Ocean Code for using table function in the calculator
Reply #4 - 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.
Back to top
 
 

If at first you do succeed, STOP, raise your standards, and stop wasting your time.
View Profile WWW   IP Logged
Pages: 1
Send Topic Print
Copyright 2002-2024 Designer’s Guide Consulting, Inc. Designer’s Guide® is a registered trademark of Designer’s Guide Consulting, Inc. All rights reserved. Send comments or questions to editor@designers-guide.org. Consider submitting a paper or model.