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
 Origin Forum
 Fitting to a maximum value in a graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Clairekun

Germany
175 Posts

Posted - 05/12/2014 :  10:34:17 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9
Operating System: Win7

Hello,

I have failed to find a similar topic, please forgive me if I skipped it somehow.

I have a plotted dataset that could be fitted to a linear regression function. My code includes both importing and plotting of this data.

My X data reaches a maximum and then goes back. I would need a code to linearly fit my data up to that maximum.

I know little about programming so please don't cry in desperation when you read what I tried . I have tried to combine plotting and fitting with plotxy and fitLR iy, setting the number of points to fit with N. I did it by defining dd=max(col(A)) before the plotting bit, and N=dd. This obviously didn't work, but I am clueless as to how to achieve this.

Thank you.

lkb0221

China
497 Posts

Posted - 05/12/2014 :  3:40:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You want to fit the first half of your data (min -> max) or the second half (max -> min)? Or the whole dataset?
Anyway, you might need to use a sub-range as input of fitLR X-function.
Something like below:

ii = list(max(col(A)),col(A)); // Return the index # of where the max X first appear
range rr = col(A)[1:$(ii)]; // Define a sub-range
fitLR iy:=rr;

Or, use the N in fitLR XF. Notice that this variable specifies the number of points to use in the linear regression. When this value is zero, all points in the range are used. When the number is a positive integer, the first N points are used. When the number is a negative integer, the last N points are used.

ii = list(max(col(A)),col(A));
fitLR iy:=col(A) N:=ii;

Hope this would help.

Zheng
OriginLab
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 05/13/2014 :  04:45:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The error that I get is the same as I did before:

Invalid column name: COL(A)
Unknown, VarName = iy, VarValue =

This is because the graph is already created, so there is no actual column A in the graph.

I tried adding the definition of ii before the plotting code bit, where I still got the last error. Using the whole code before plotting does nothing.
Go to Top of Page

lkb0221

China
497 Posts

Posted - 05/14/2014 :  09:53:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Then specify the book name and sheet name in the range declare.
For example:
range rr = [Book1]sheet1!col(A)

And let it be the input for XFs.
For example:
... iy:=rr ... or max(rr)

Zheng
OriginLab

Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 05/14/2014 :  12:21:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Since I am obtaining those graphs by importing and plottng data. Is there any way to include the fitting part so that I don't have to work with every plot individually?

Thanks!

quote:
Originally posted by lkb0221

Hi,

Then specify the book name and sheet name in the range declare.
For example:
range rr = [Book1]sheet1!col(A)

And let it be the input for XFs.
For example:
... iy:=rr ... or max(rr)

Zheng
OriginLab



Go to Top of Page

lkb0221

China
497 Posts

Posted - 05/14/2014 :  2:49:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You should do the analysis before plotting.
I suggest you making a analysis template for batch processing, and it should be able to do all your fitting and graphing works.

Zheng
OriginLab
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 05/20/2014 :  3:10:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I'm trying to generate an analysis template and it works very nicely. However, I would like to be able to have the fitted plot and fitting summary in a separate window, too (having the summary embedded to the graph, just as if I had fitted the data directly from the plot).

How could I do this? Since I am going to use it very often, I plan to add a script button. Therefore, I'd appreciate it if there was labtalk script I could use for this.

Thank you.
Go to Top of Page

lkb0221

China
497 Posts

Posted - 05/20/2014 :  5:21:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If using script button, then there is no way to batch processing.
How about using worksheet script (Worksheet: Worksheet Script), run after import. And let the graph be a single sheet (add graph as sheet).
In this way you can still use this template to batch processing.
But this will require more coding works.

Zheng
OriginLab
Go to Top of Page

Clairekun

Germany
175 Posts

Posted - 05/20/2014 :  6:40:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I believe I could run a script to open my batch template and then import my data, so that part would not be a problem.

Anyway, the problems I have found are now different from the initial topic, so I'll start a new one that shows my question more clearly.

Thanks again.
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