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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Manipulate column plot it and integrate

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
bo257 Posted - 05/01/2003 : 10:23:02 AM
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.
1   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 05/01/2003 : 2:50:40 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000