My first suggestion is to move the Add Rows() up higher into the looping. Add Rows() is a pretty slow function, so if you could add all of the rows you need for the data table, to right after the initial New Table(), that would make the program much faster. That would also mean that you would have to add in an overall row counter, to keep track of what row you are working on, instead of using N Rows().
Names Default To Here( 1 );
// Read in Excel file
dt = Open(
"c:\users\txjim\documents\read in issue\example.xlsx"
/*"<your path to the excel file>\example.xlsx"*/,
Worksheets( "example" ),
Use for all sheets( 1 ),
Concatenate Worksheets( 0 ),
Create Concatenation Column( 0 ),
Worksheet Settings(
1,
Has Column Headers( 0 ),
,
Number of Rows in Headers( 1 ),
Headers Start on Row( 1 ),
Data Starts on Row( 1 ),
Data Starts on Column( 1 ),
Data Ends on Row( 0 ),
Data Ends on Column( 0 ),
Replicated Spanned Rows( 1 ),
Replicated Spanned Headers( 0 ),
Suppress Hidden Rows( 1 ),
Suppress Hidden Columns( 1 ),
Suppress Empty Columns( 1 ),
Treat as Hierarchy( 0 ),
Multiple Series Stack( 0 ),
Import Cell Colors( 0 ),
Limit Column Detect( 0 ),
Column Separator String( "-" )
)
);
// Get Y Matrix
Ymat = {};
For( i = 3, i <= N Col( dt ), i++,
If( Column( i )[1] != "",
Ymat = Ymat |/ Matrix( Num( Column( i )[1] ) )
)
);
// Get rid of unrequired cells, and get the X and Z matrices
dt << select rows( [1, 2, 3] );
dt << delete rows;
dt << delete column( 2 );
// Convert all columns to numerics
For( i = 1, i <= N Col( dt ), i++,
Column( dt, i ) << data type( numeric )
);
// Get X matrix
Xmat = Column( dt, 1 ) << get as matrix;
dt << delete column( 1 );
// Get Z matrix
Zmat = dt << get as matrix;
// Create new data table, and output the data
dtFinal = New Table( "Converted", New Column( "X" ), New Column( "Y" ), New Column( "Z" ) );
dtFinal << add rows( N Rows( Xmat ) * N Rows( Ymat ) * N Rows( Zmat ) * N Cols( Zmat ) );
rowcnt = 0;
For( Xcnt = 1, Xcnt <= N Rows( Xmat ), Xcnt++,
For( Ycnt = 1, Ycnt <= N Rows( Ymat ), Ycnt++,
For( Zrowcnt = 1, Zrowcnt <= N Rows( Zmat ), Zrowcnt++,
For( Zcolcnt = 1, Zcolcnt <= N Cols( Zmat ), Zcolcnt++,
rowcnt++;
dtFinal:X[rowcnt] = Xmat[Xcnt];
dtFinal:Y[rowcnt] = Ymat[Ycnt];
dtFinal:Z[rowcnt] = Zmat[Zrowcnt, Zcolcnt];
)
)
)
);
dtFinal << Scatterplot 3D(
Y( :X, :Y, :Z ),
Frame3D(
Set Grab Handles( 0 ),
Set Walls( 1 ),
Set Rotation( -54, 0, 38 ),
Set Text Scale( 2 ),
Set Line Scale( 1 ),
Set Marker Transparency( 1 ),
Set Marker Quality( 0.25 ),
Set Marker Scale( 1 ),
Set View Perspective( 0.1 ),
Set View Zoom( 1 )
)
);
Jim