The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Manipulate column plot it and integrate
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bo257

USA
13 Posts

Posted - 05/01/2003 :  10:23:02 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi;
I would like to automate a process, which done manually is rather time consuming. I have a worksheet with columns C1 to C100;
I would like to change the column values for each column (col(C1)=(10^(col(C1)/10)*0.001)^0.5), plot the column and get the total integral area under the curve and save that value in a separate worksheet such that row 1 would contain the value for C1, row 2 the calue for C2, etc...
Is this possible?
If someone could give me hint where to start from, that would be great.

Best,

barb.

easwar

USA
1965 Posts

Posted - 05/01/2003 :  2:50:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000