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
 access column in loop

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
DB-L Posted - 06/17/2014 : 07:48:43 AM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: XP, origin 9.1

Hello, I new on origin and I am blocked in C++ code.
I wan't to extract root from a polynomial. I wrote a bisection method which run good.
But now, I want to input the values of two column in my worksheet and output the root in an other column.
Here is the code. If someone could help me, it will be very kind...


double function (double x, double K, double P, double z, double y)
{
return K * P * (y - x )* pow((1 - (z * x) ),z) - ( z * x)
}
void dichotomie() {
double leftpt, rightpt, midpt, epsilon = .00000000001;
double midvalue, rtvalue, root;

Worksheet wks = Project.ActiveLayer();
double K = wks.Cell(0, 4);
double P = wks.Cell(0, 3); // this value should be in a column
double z = wks.Cell(0, 5);
double y = wks.Cell(0, 0);
leftpt = 0.0, rightpt = 0.4;
do {
midpt = (leftpt + rightpt) / 2.0;
rtvalue = function(rightpt, K,P , z, y);
midvalue = function(midpt, K, P, z, y);
if (rtvalue * midvalue >= 0)
rightpt = midpt;
else leftpt = midpt;
} while ((rightpt - leftpt) > epsilon);
root = (rightpt + leftpt) / 2.0;

wks.SetCell(0, 8, root); // the value should be different at each row

return;
}
3   L A T E S T    R E P L I E S    (Newest First)
DB-L Posted - 06/18/2014 : 06:02:38 AM
Hello Jessie, I just sent you the worksheet by e-mail.
I want to calculate each row for obtained a root value of each P value.
Thank you for your consideration.
Best regards.
JessieWoo Posted - 06/18/2014 : 05:42:58 AM
Hi David,

I am not sure if you want to calculate each row of your data. Would you please send me your data worksheet, so I can better understand your question.

You can follow the instruction in the link below to send me the file.
http://www.originlab.com/index.aspx?go=Support&pid=752

Jessie
OriginLab Corp.
DB-L Posted - 06/18/2014 : 03:54:41 AM
I noticed that my formulation wasn't clear.
In the first part of the code, I declare the function for which I want to get the root.
Next, int the first part of "dichotomie", I input the parameters of the function. For the value contained in one cell, there is no problem.
I'm stuck for two critical points (for me I mean...) :

1) the value of P which has to be the colonne "P" in my worksheet
2) and for return of the root "root" which has to be also in a column "root" in the worksheet.

I'm able to create a new column or a new worksheet but in need to use the values of column for calculation...
Or maybe it's better to use labtalk for manipulating column? But in this case how can I write my loop for bisection method?

Is there anybody to give help?

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