Hi Barb,
Try the code posted here. Once you compile and link this, you can execute from script window by typing:
compute wksname begincol endcol
So, if your source data worksheet is Data1, and you have cols C1 thru C100 at column positions of say 2 thru 101 (I am assuming 1st col is X in this case, which is common to all other columns), you can then issue the command:
compute data1 2 101
I did not include code for plotting. If you are only interested in getting area under curve, there is no need to plot.
The code creates a new results worksheet where the first column will be a label column which will contain the names of the columns from your data worksheet. The second column in the results wks will have the integration values.
Easwar
OriginLab.
void compute(string strDataWks, int iBegin, int iEnd)
{
int iNumCols = iEnd - iBegin + 1;
if(iNumCols < 1)
{
printf("incorrect column number specification!\n");
return;
}
// Declare data worksheet and check validity
Worksheet wksData(strDataWks);
if(!wksData){
printf("invalid data worksheet!\n");
return;
}
// Create a results worksheet
Worksheet wksResult;
wksResult.Create("Origin.otw");
//Declare datasets in results worksheet
Dataset dsLabel(wksResult, 0);
Dataset dsValue(wksResult, 1);
dsLabel.SetSize(iNumCols);
dsValue.SetSize(iNumCols);
// Loop over specified columns in data worksheet, compute, integrate, and store results
for(int iCol = 0; iCol < iNumCols; iCol++)
{
Dataset dsData(wksData, iCol + iBegin - 1);
if(!dsData)
{
printf("invalid data column!\n");
return;
}
// Get name of data column and store in result wks
string strColName = dsData.GetName();
dsLabel.SetText(iCol, strColName);
// Loop thru each element in data column and do the math
int iSize = dsData.GetSize();
for(int iRow = 0; iRow < iSize; iRow++)
{
dsData[iRow] = ( 10^( dsData[iRow] / 10.0 ) * 0.001) ^ 0.5;
}
// Perform integration and store result
Curve crvMyCurve(strColName); // Create Curve object to integrate
if(!crvMyCurve)
{
printf("invalid curve object!\n");
return;
}
IntegrationResult irMyResults; // Origin C structure to store integration results
bool bErr = Curve_integrate( &crvMyCurve, &irMyResults ); // Perform integration
dsValue[iCol] = irMyResults.Area;
}
// Set 1st col of result worksheet to type label
wksResult.Columns(0).SetType(OKDATAOBJ_DESIGNATION_L);
}
Edited by - easwar on 05/02/2003 09:44:55 AM