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
 LabTalk Forum
 finding fit error for movslope function

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
aengwall Posted - 05/22/2018 : 5:21:20 PM
Does anyone have an idea how to associate or extract error values for the fits found with the movslope function? My ideal output would be one column with Fx=movslope(x,y,interval) and then a yEr column with the fit errors beside it for easy plotting.

Thanks for your help.
4   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 05/23/2018 : 10:54:49 PM
Hi,

I think you missed the semicolon at the end of Line 4, it should be:
int zerot=Index(0,col(G));

Also, to avoid conflict with column short name, it is recommended to rename “range b” , such as “range rb”. Please refter to the variable naming rules here:
https://www.originlab.com/doc/LabTalk/guide/Data-Types-and-vars#Variable_Naming_RulesVariable_Naming_Rule

Hope it helps.

Regards,
Yuki
OriginLab
aengwall Posted - 05/23/2018 : 8:57:29 PM
Actually, I think I've just about got it:

int nRows = wks.nRows;
int maxt = max(col(G));
int nInterval = 50;
int zerot=Index(0,col(G))
range b= X;
range rbErr = Y;
for(int ii = 1; ii < (maxt/nInterval); ii++)
{
int nBegin = zerot + Index((ii - 1) * nInterval,col(G));
int nEnd = zerot + Index((ii) * nInterval,col(G));
range ee = (G,O)[$(nBegin):$(nEnd)];
fitlr iy:=ee;
b[$((nBegin+nEnd)/2)] = fitlr.b;
rbErr[$((nBegin+nEnd)/2)] = fitlr.berr;
}


except I'm no longer getting an output for the slope b, just the error. I welcome any thoughts for troubleshooting.
aengwall Posted - 05/23/2018 : 4:51:48 PM
Thank you Yuki, your reply was very helpful. I hope you can help me with one further refinement. How would I go about setting the interval to be a function of change in time (the first column), rather than a set number of data points? I had been using an additional column of Fx=20/Diff(A) to determine the interval of data points per 20 seconds, but I'm not sure how to translate that into the script.
yuki_wu Posted - 05/23/2018 : 04:37:39 AM
Hi,

You could write a piece of script to loop over the subranges and then perform linear fitting on the subrange respectively. Take an example:
int nRows = wks.nRows;
int nInterval = 5;
range raErr = col(3);
range rbErr = col(4);
for(int ii = 1; ii < (nRows/nInterval); ii++)
{
	int nBegin = 1 + (ii - 1) * nInterval;
	int nEnd = 5 + (ii - 1) * nInterval;
	range ee = [Book1]Sheet1!(1,2)[$(nBegin):$(nEnd)];
	fitlr iy:=ee;
	raErr[$(nBegin)] = fitlr.aerr;
	rbErr[$(nBegin)] = fitlr.berr;
}

You could find more details of fitLR X-Function here:
https://www.originlab.com/doc/X-Function/ref/fitLR

Regards,
Yuki
OriginLab

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