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
 Linear fit over over whole axis range with LabTalk

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
VauWe Posted - 10/10/2022 : 10:53:11 AM
OriginPro 2022b (64bit) / 9.9.5.167
Operating System: Win10
----------------------------

I do a linear fit with a labtalk script with 12 data points from 300 - 600 K (as x-axis). How can I manage the fit over the whole x-axis down to 0 K with labtalk? The script is as follows:

tree lrGUI;  													
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;			
lrGUI.GUI.InputData.Range1.X$ = col(2);							
lrGUI.GUI.InputData.Range1.Y$ = col(14)[1:$(NumTemp-NumTempCool)];		
xop execute:=report iotrgui:=lrGUI otrresult:=lrOut;					
xop execute:=cleanup;												plotxy iy:=[TQdata]4!(1,2) plot:=200 ogl:=[TQFWHMcm-1Graph]1!;	

Thanks a lot in advance

vauwe

6   L A T E S T    R E P L I E S    (Newest First)
VauWe Posted - 10/18/2022 : 03:01:18 AM
Hi Yiming Chen,

I put the data points in the graph a few lines above which works perfect. The last line of my code is needed to put the fitted line in the graph.


plotxy iy:=(2,14)[1:$(NumTemp-NumTempCool)] plot:=201 ogl:=[TQFWHMcm-1Graph]1!;
range ll = [TQFWHMcm-1Graph]1!;
ll.x.from = 0;
ll.x.to = 700;
ll.x.inc = 100;
ll.x.rescale = 4;		
ll.y.from = 0;
ll.y.to = 2000;
ll.y.inc = 200;
ll.y.rescale = 4;				

tree lrGUI;  														
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;				
lrGUI.GUI.InputData.Range1.X$ = col(2);								
lrGUI.GUI.InputData.Range1.Y$ = col(14)[1:$(NumTemp-NumTempCool)];	
lrGUI.GUI.Graph1.XDataType.Range = 2;
lrGUI.GUI.Graph1.XDataType.Min.SetAttribute("Auto",0);
lrGUI.GUI.Graph1.XDataType.Min = 0;									
lrGUI.GUI.Graph1.XDataType.Max.SetAttribute("Auto",0);
lrGUI.GUI.Graph1.XDataType.Max = 650;								
xop execute:=report iotrgui:=lrGUI otrresult:=lrOut;				
lrGUI.GUI.Output.PlotSettings.PasteResultTable.SetAttribute("Use", 3);
xop execute:=cleanup;		
plotxy iy:=[TQdata]4!(1,2) plot:=200 ogl:=[TQFWHMcm-1Graph]1!;	


YimingChen Posted - 10/17/2022 : 11:31:48 AM
Can you create the graph first, then run the linear fit. See the example code below:

filename$ = system.path.program$ + "Samples\Curve Fitting\Linear Fit.dat"; 
newbook;impASC filename$;  //create a graph with the data
range data = [<active>]1!(1, 2);
plotxy data plot:=201 ogl:=<active>;  
xop execute:=init classname:=FitLinear iotrgui:=lrGUI; 
%A =  xof(%C);   //Specify XY datasets
lrGUI.GUI.InputData.Range1.X$ = %A;
lrGUI.GUI.InputData.Range1.Y$ = %C;       

lrGUI.GUI.Graph1.XDataType.Range = 2;
lrGUI.GUI.Graph1.XDataType.Min.SetAttribute("Auto",0);
lrGUI.GUI.Graph1.XDataType.Min = 0;									
lrGUI.GUI.Graph1.XDataType.Max.SetAttribute("Auto",0);
lrGUI.GUI.Graph1.XDataType.Max = 650;								
xop execute:=report iotrgui:=lrGUI otrresult:=lrOut;			
lrGUI.GUI.Output.PlotSettings.PasteResultTable.SetAttribute("Use", 3);
xop execute:=cleanup;	
VauWe Posted - 10/17/2022 : 10:44:40 AM
No, is not added automatically to my graph.

tree lrGUI;  														
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;				
lrGUI.GUI.InputData.Range1.X$ = col(2);								
lrGUI.GUI.InputData.Range1.Y$ = col(14)[1:$(NumTemp-NumTempCool)];
lrGUI.GUI.Graph1.XDataType.Range = 2;
lrGUI.GUI.Graph1.XDataType.Min.SetAttribute("Auto",0);
lrGUI.GUI.Graph1.XDataType.Min = 0;									
lrGUI.GUI.Graph1.XDataType.Max.SetAttribute("Auto",0);
lrGUI.GUI.Graph1.XDataType.Max = 650;								
xop execute:=report iotrgui:=lrGUI otrresult:=lrOut;			
lrGUI.GUI.Output.PlotSettings.PasteResultTable.SetAttribute("Use", 3);
xop execute:=cleanup;												
plotxy iy:=[TQdata]4!(1,2) plot:=200 ogl:=[TQFWHMcm-1Graph]1!;


Any idea to put the fit result table in my "TQFWHMcm-1Graph"?

Regards
vauwe
YimingChen Posted - 10/14/2022 : 10:58:10 AM
Isn't it added by default? If not, you can add a line of script:
LRGUI.GUI.Output.PlotSettings.PasteResultTable.SetAttribute("Use", 3);


VauWe Posted - 10/14/2022 : 10:20:19 AM
Thanks a lot, it works!
One other question, how can I put the "summary table" of the fit in my graph?

Summary table:
Gleichung y = a + b*x
Zeichnen FWHM_SLAO22291B1
Gewichtung Keine Gewichtung
Schnittpunkt mit der Y-Achse 845.67633 ± 17.0951
Steigung 1.40227 ± 0.0373
Summe der Fehlerquadrate 1691.65891
Pearson R 0.99613
R-Quadrat (COD) 0.99228
Kor. R-Quadrat 0.99157



Thanks a lot for your help.

vauwe
YimingChen Posted - 10/11/2022 : 3:14:19 PM
If you are talking about the fitted line range, please try the script below:

tree lrGUI;  													
xop execute:=init classname:=FitLinear iotrgui:=lrGUI;			
lrGUI.GUI.InputData.Range1.X$ = col(2);							
lrGUI.GUI.InputData.Range1.Y$ = col(14)[1:$(NumTemp-NumTempCool)];
LRGUI.GUI.Graph1.XDataType.Range = 2;
LRGUI.GUI.Graph1.XDataType.Min.SetAttribute("Auto",0);
LRGUI.GUI.Graph1.XDataType.Min = 0;
LRGUI.GUI.Graph1.XDataType.Max.SetAttribute("Auto",0);
LRGUI.GUI.Graph1.XDataType.Max = 600;		
xop execute:=report iotrgui:=lrGUI otrresult:=lrOut;					
xop execute:=cleanup;	

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