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
 Fit linear imprecisely

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
70WorkRoom Posted - 07/14/2007 : 11:07:06 AM
Origin Version (Select Help-->About Origin): Origin pro v7.5
Operating System:Windows 2000

I have a group of data,as follow:
0.00332 -12.68603
0.00329 -12.53321
0.00326 -12.39201
0.00323 -12.26425
0.00321 -12.12347
0.00318 -11.9675
0.00316 -11.82056
0.00313 -11.67324
0.00311 -11.52321
0.00308 -11.39422
0.00306 -11.28117
0.00304 -11.18197
0.00301 -11.10305
0.00299 -11.02593
0.00297 -10.95195
0.00295 -10.8843
0.00293 -10.82642
0.00291 -10.78781
0.00288 -10.72988
0.00286 -10.72491
0.00284 -10.69234
0.00282 -10.66051
0.0028 -10.62292
0.00278 -10.6093
0.00276 -10.589
0.00275 -10.5825
0.00273 -10.55663
0.00271 -10.56111
0.00269 -10.49916
0.00267 -10.57418
0.00265 -10.54662
0.00264 -10.54153
0.00262 -10.49945
0.0026 -10.50622
0.00259 -10.53643
0.00257 -10.50989
0.00255 -10.55342
0.00254 -10.48582
0.00252 -10.452
0.0025 -10.45654
0.00249 -10.43576
0.00247 -10.51505
0.00246 -10.47342
0.00244 -10.38305
0.00243 -10.38145
0.00241 -10.4062
0.0024 -10.34437
0.00238 -10.36644
0.00237 -10.31843
0.00236 -10.2648
0.00234 -10.12262
0.00233 -10.23017
0.00232 -10.24602
0.0023 -10.24964
0.00229 -10.32215
0.00228 -10.16118
0.00226 -10.24396

I use the origin Menu to Fit Linear,the result is:

And it can return a result log.

But when I Use my function to fit linear,the result is:


The X-axis is different from the picture 1.And it can't return the result log.

My function is as follow:

void FitLinear(string strTemplate,string strData)
{
GraphPage grph;
BOOL bOK = grph.Create(strTemplate,CREATE_VISIBLE);
if(!bOK)
return; //根据模板生成Graph窗口

GraphLayer grlay = grph.Layers(0);
Curve cv(strData); //将第一层链接到一个新的GraphLayer对象
//Curve cv("Data1_a", "Data1_b");
int nPlot = grlay.AddPlot(cv); //将数据组链接到新曲线对象,
//并链接曲线对象到GraphLayer对象

if(nPlot >= 0)
{
grlay.DataPlots(nPlot).SetColor(3,TRUE); //设置曲线颜色为蓝色(3)
grlay.Rescale();
}

LT_execute("lr " + strData + ";");
LT_execute("type Slope is $(lr.b)");
LT_execute("type Intercept is $(lr.a)");
LT_execute("%E=$(round((abs(lr.b)*8.314/1000),2));");
LT_execute("type %E;");
}
2   L A T E S T    R E P L I E S    (Newest First)
70WorkRoom Posted - 07/16/2007 : 04:57:17 AM
thank you very much.
Mike Buess Posted - 07/14/2007 : 1:01:26 PM
quote:
The X-axis is different from the picture 1.
X axes look the same to me. Perhaps you mean Y axes? You can rescale as shown below.

quote:
And it can't return the result log.
Type command normally goes to the script window. Use type.redirection to send to results log.

LT_execute("lr " + strData); // perform linear fit
grlay.Rescale(); // rescale
grlay.Y.Inc = 0.5; // change Y tick increment to 0.5
grlay.LT_execute("legend"); // redraw legend
LT_execute("old=type.redirection");
LT_execute("type.redirection=16"); // redirect type to results log
LT_execute("type Slope is $(lr.b)");
LT_execute("type Intercept is $(lr.a)");
LT_execute("%E=$(round((abs(lr.b)*8.314/1000),2));");
LT_execute("type %E;");
LT_execute("type.redirection=old"); // reset redirection

Mike Buess
Origin WebRing Member

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