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
 Origin Forum
 Function with parameter(s)

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
Gandi Posted - 02/28/2011 : 7:27:35 PM
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
4   L A T E S T    R E P L I E S    (Newest First)
Gandi Posted - 03/06/2011 : 5:54:59 PM
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".
Penn Posted - 03/01/2011 : 10:34:28 PM
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
Gandi Posted - 03/01/2011 : 06:56:46 AM
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.
Penn Posted - 03/01/2011 : 01:46:32 AM
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

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