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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Linear fit over over whole axis range with LabTalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

VauWe

9 Posts

Posted - 10/10/2022 :  10:53:11 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

YimingChen

1683 Posts

Posted - 10/11/2022 :  3:14:19 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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;	
Go to Top of Page

VauWe

9 Posts

Posted - 10/14/2022 :  10:20:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

YimingChen

1683 Posts

Posted - 10/14/2022 :  10:58:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Isn't it added by default? If not, you can add a line of script:
LRGUI.GUI.Output.PlotSettings.PasteResultTable.SetAttribute("Use", 3);


Go to Top of Page

VauWe

9 Posts

Posted - 10/17/2022 :  10:44:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

YimingChen

1683 Posts

Posted - 10/17/2022 :  11:31:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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;	
Go to Top of Page

VauWe

9 Posts

Posted - 10/18/2022 :  03:01:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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!;	


Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000