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
 Automation of repetitive tasks
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ungat

Belgium
Posts

Posted - 05/25/2005 :  08:16:32 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System:Windows XP

Hello, my analytical work involves a lot of repetitive tasks:

1)I have to import several dozens of ASCII files (each file has two columns A(X),B(Y))

2)Rename each Y column by the name of worksheets

3)normalize each Y column by dividing column Y by the area of its curve. (plot Y and perform integration of its curve)

4)multiplie column X by normalized column Y and put the result in a third column Y called C

5) perform integration of column C and put the result in a column D
there is an example here:

/*------------------------------------------------------------------------------*
* File Name: NormalizeAllYColumns.c *
* Creation: ER, 02/07/05 *
* Purpose: Programming Example *
* Copyright (c) OriginLab Corp.2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 *
* All Rights Reserved *
* *
* Modification Log: *
*------------------------------------------------------------------------------*/

#include <Origin.h>

////////////////////////////////////////////////////////////////////////////////////
// This function normalizes the data in all Y columns, dividing the column values
// by the max value found in the column.
//
void normalize_all_y_columns()
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}

foreach( Column col in wks.Columns )
{
if( OKDATAOBJ_DESIGNATION_Y == col.GetType() )
{
Dataset ds(col);
double dMin, dMax;
ds.GetMinMax(dMin, dMax);
ds /= dMax;
}
}
}
////////////////////////////////////////////////////////////////////////////////////

but I don't want to normalize the data in all Y columns, dividing the column values by the max value found in the column but dividing the column values by the area value of their curves.

Please, could you help me to create this function ?

Thanks

skelton

China
Posts

Posted - 06/07/2005 :  05:50:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Is this function OK for task4?
void task3()
{ Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}
Dataset dx(wks, 0);
Dataset dy(wks, 1);
Curve cr(dx,dy);
double areay=area(cr);
dy /= areay;
}


//By the way, I give you the functions for task 4 and task 5.
void task4()
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}
wks.AddCol();
Dataset dx(wks,0);
Dataset dy(wks,1);
Dataset dc(wks,2);
dc=dx*dy;
return;
}

void task5()
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}
Dataset dx(wks,0);
Dataset dc(wks,2);
Curve cr(dx,dc);
double areaC=area(cr);
wks.AddCol();
wks.SetCell(0,3,areaC);
return;
}

Edited by - skelton on 06/07/2005 06:30:29 AM
Go to Top of Page

ungat

Belgium
Posts

Posted - 06/13/2005 :  08:48:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Skelton, thank you very much;
I am a beginner in Origin C compiling and I am not succeed in using your program; please could you complete this program for it becomes ready to work, because I don't know how to submit it.

Thank you very much again.

quote:

Is this function OK for task4?
void task3()
{ Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}
Dataset dx(wks, 0);
Dataset dy(wks, 1);
Curve cr(dx,dy);
double areay=area(cr);
dy /= areay;
}


//By the way, I give you the functions for task 4 and task 5.
void task4()
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}
wks.AddCol();
Dataset dx(wks,0);
Dataset dy(wks,1);
Dataset dc(wks,2);
dc=dx*dy;
return;
}

void task5()
{
Worksheet wks = Project.ActiveLayer();
if( !wks )
{
out_str("Active layer is not a worksheet!");
return;
}
Dataset dx(wks,0);
Dataset dc(wks,2);
Curve cr(dx,dc);
double areaC=area(cr);
wks.AddCol();
wks.SetCell(0,3,areaC);
return;
}

Edited by - skelton on 06/07/2005 06:30:29 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