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
 Function with parameter(s)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Gandi

USA
Posts

Posted - 02/28/2011 :  7:27:35 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I'd like to create functions via "Graph --> Add Function Graph" which are identical but use different paramter(s) each. Ideally I'd have a workbook which contains two columns with the parameters and I could then create a function f(x,par) to be plotted in the graph, where par is retrieved from the workbook. For example "func5" would use par(5), i.e. the value of the cell in the second column of the workbook where the corresponding cell in the first column equals 5.

However, I don't know how to access workbook cells from the "Add Function Graph" dialogue box. Using the [Workbook]Sheet!Column(x) syntax doesn't seem to work. I can access variables (defined in the script window) in the "Add Function Graph" dialogue box, but I'm wondering if it's possible to use the contents of specific cells in a workbook instead. For obvious reasons, when one wants to plot the same function with different parameter(s) many times, defining a separate variable in the script window for each function is rather tedious. One workbook that contains all parameters would be much more elegant.

Any help is appreciated!

_____________________________
Origin Ver. and Service Release: 8 SR6
Operating System: Win XP

Penn

China
644 Posts

Posted - 03/01/2011 :  01:46:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Currently, Origin does not support accessing workbook cell from "Add Function Graph" dialog as you have mentioned.

Maybe you can use the Set Values dialog, the following tutorials can help how to use this dialog, Setting Column Values, Set Column Values, and this. After setting column values for each function, create graph with these columns.

Penn

Edited by - Penn on 03/01/2011 02:00:24 AM
Go to Top of Page

Gandi

USA
Posts

Posted - 03/01/2011 :  06:56:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn,

thanks for your prompt reply.

Using the "Set Column Values" dialog might be a suitable workaround. However, can I call a function which I have defined previously from there? Ideally, each column should be filled with values calculated from the same function but using a different parameter. I don't want to define the same function in the "Set Column Values" dialog for each column.

I've tried X-Functions, but I couldn't get it to work.
Go to Top of Page

Penn

China
644 Posts

Posted - 03/01/2011 :  10:34:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can define your function in Origin C. The following steps are the simple example.

1. Click the Code Builder button to open Code Builder.

2. Select menu File: New to open the New File dialog, give a File Name and then click OK to create a C File with the default settings.

3. In the newly created C File, I will define a function like:

double test_set(double x, double a)
{
	double y;
	y = x+a;
	return y;
}

4. Choose menu Tools: Build to compile and link the file.

5. Go back to Origin main interface, I will set column B by using this function like below:



6. To make this defined function available once Origin starts, go back to Code Builder, drag-and-drop the newly created file from the User folder to the System folder in the Workspace. See more details in this page.

Penn
Go to Top of Page

Gandi

USA
Posts

Posted - 03/06/2011 :  5:54:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Penn,

this works like a charm, thanks a lot! Since it's possible to call an Origin C function from the "Add Function Graph" dialog I'll go with that, so I don't even need to create a workbook and use "Set Column Values".
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