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
 Y axis fitting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kdsaransh

India
89 Posts

Posted - 01/16/2015 :  05:57:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

Is there a way to fit the graph as per the Y axis value. Actually i want to fit a graph whose Y axis value is from 40dB to 0dB. since my x axis value changes from sheet to sheet, hence fixing the ROI region for x value gives me a wrong intercept and slope value and is also not fitting properly.


Thanks and regards,

Rajesh Agarwal

lkb0221

China
497 Posts

Posted - 01/16/2015 :  09:28:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use Xindex function to get the index number of corresponding X value by a Y value.
http://www.originlab.com/doc/LabTalk/ref/Xindex-func

Zheng
OriginLab
Go to Top of Page

kdsaransh

India
89 Posts

Posted - 01/16/2015 :  11:03:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Thanks , but this doesn't solves my problem. I don't want to be dependent on x axis value. I simply want to set the data marker to 0db and 40 db of Y axis and then do the fitting using script. I hope that its clear. Should i post my code ???

Thanks
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/16/2015 :  3:30:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Then simply switch your XY.
for example:
nlbegin iy:=(1,2) func:=gauss; // Before.
nlbegin iy:=(2,1) func:=gauss; // After
Go to Top of Page

kdsaransh

India
89 Posts

Posted - 01/17/2015 :  01:41:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks,

But i am doing linear fitting.

My code is as follows:

string fns, path$="C:\Users\babia\Desktop\origin";
findfiles f:=fns$ e:="*.dat";
int n = fns.GetNumTokens(CRLF);
string bkName$;
string fname$;
for(int ii = 1; ii<=n; ii++)
{
impasc fname:=fns.GetToken(ii, CRLF)$ options.ImpMode:=1 options.Sparklines:=0 options.Names.FNameToSht:=0
options.Names.AutoNames:=0
options.Names.FNameToBk:=0
options.Names.FNameToBkComm:=0
options.Names.FNameToColComm:=1
options.Names.FPathToComm:=0;

Col($(2*ii-1))[L]$="Frequency";
Col($(2*ii))[L]$="Gain";
Col($(2*ii-1))[U]$="Hz";
Col($(2*ii))[U]$="dB";

}
for(int ii = n-1; ii>=1; ii--)
{
del Col($(2*ii+1));
}

win -r %H mybook51 ; // rename a workbook
Win -a mybook51; //activate a workbook

for(int ii = 2; ii<=n+1; ii++)
{
range rWa = [mybook51]sheet1!; // Define a worksheet object range
rWa.colSel(ii-1,0); // deselect col 2.
rWa.colSel(ii,1); // select column 2. 1 stands for select. If 0 stands for deselect.
plotxy iy:= [mybook51]Sheet1!(1,$(ii)) ogl:=[<new template:="
C:\Users\babia\Documents\OriginLab\91\User Files\ac_nonfitting.otp" name:=samplegraph>];
// renames the graph name to worksheet comment name.

page.label$ = %(1,@LC);
layer -a;

layer.x.from = 60; //Set the end value
layer.x.to = 900000; //Set the increment value
//layer.x.inc = 2;

StartRange=70;
EndRange=950000;
mks1=xindex(StartRange,%C);
mks2=xindex(EndRange,%C);

// from quick fit gadget, using fix ROI
addtool_quickfit trroi.XScale.leftx:=70 trroi.XScale.rightx:=100000 trroi.XScale.fixscale:=1 trroi.ShowTop.RSqr:=1 trroi.RectColor:=17 trtable.Params:=2 trtable.ReduChisq:=0 trtable.Correlation:=0 trreport.ReduChisq:=0 trreport.Correlation:=0;

gadget gg = rect; //declare LT gadget variable
gg.output();

range p1=1!1; //The first plot
set %c -c 4; //Change the line's color
set %c -d 1; //Change the line's style.

Echo=1;
Echo=2;
Echo=3;
Echo=4;
Echo=7
}


Please help me out.

thanks
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/19/2015 :  10:25:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

You can try plot your X against your Y:

plotxy iy:= [mybook51]Sheet1!(1,$(ii)) // Before
plotxy iy:= [mybook51]Sheet1!($(ii),1) // After
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