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
 linear regression stalls origin

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
cosy Posted - 07/28/2004 : 12:46:57 PM
Hi,
I have a large dataset (a real time data acquisition). I have set up a originC program to continuosly calculate the linear regression parameters and display it. I saw that origin wasnt able to respond to any events when the program was running in the background. This happened though there was a sleep (for 5 seconds) included in the loop.
My code goes like this :
void TricLr()
{
Dataset ds1;
Dataset ds2;

Dataset dsA("TricData_Time");
Dataset dsB("TricData_Scaler1C0");
string str;


double dCoeff[4];
int ii;

double data;
waitCursor cur;

Curve crv("TricData_Time","TricData_Scaler1C0");

SetDataDisplayText("Computing Linear Regression parameters ...Hit Esc to Stop.");
int aa = dsA.GetUpperBound();
for (ii=0;ii < aa && !cur.CheckEsc();ii++)
{

fitpoly_range(crv, ii, ii+9, 2, &dCoeff); // Fit 1nd degree polynomial to entire curve
data = -(dsB[ii]/dCoeff[1])/3600000;
str.Format("Life Time %f hours", data);
SetDataDisplayText(str);
//printf("LifeTime : %f",data);
aa = dsA.GetUpperBound();
Sleep (5000);

}

if(cur.CheckEsc())
SetDataDisplayText("Computation interrupted!");
}

Does anyone have an idea of what could be wrong ?
Thanks,
Deepak Samuel.
2   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 07/30/2004 : 4:59:00 PM
Hi Deepak,

Using "sec -p" from within OC will free up Origin for doing other tasks as long as those tasks do not involve compiling Origin C files.

If you want to free up Origin C to compile other files as well, another approach is to push the timer into script code, and call Origin C only for fitting one segment of the data at a time, such as below:

Easwar
OriginLab


//Script code starts here.....
limit(TricData_Time); // Get dataset size
iPts = limit.size;
ii = 0; // point to first row
def TimerProc // Define Procedure for Timer
{
ii++; // move to next row
if(ii > iPts - 9) // if past last segment, turn timer off and quit
{
timer -k;
return;
};
TricLr(ii); // Call OC function that fits one segment
};
timer 5; // Run Timer Procedure once every 5 secs
//
// script code ends here
//
//
//
//
// OC code below:
// please check for accuracy such as data begin/end settings
// note LabTalk counts from 1 and OC from 0
void TricLr(int iBegin)
{
string str;
double dCoeff[4];
int ii;
double data;
Dataset dsB("TricData_Scaler1C0");
Curve crv("TricData_Time","TricData_Scaler1C0");
fitpoly_range(crv, iBegin - 1, iBegin + 8, 2, &dCoeff); // Fit 1nd degree polynomial to entire curve
data = -(dsB[iBegin]/dCoeff[1])/3600000;
str.Format("Life Time %f hours", data);
SetDataDisplayText(str);
}
//
// OC code ends




Edited by - easwar on 07/30/2004 5:06:48 PM
cpyang Posted - 07/30/2004 : 4:17:12 PM
replace

Sleep (5000);

with

LT_execute("sec -p 5");


CP



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