Author |
Topic |
|
cjs7
Canada
2 Posts |
Posted - 07/08/2010 : 11:26:45 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): 8.0 Operating System: Windows 7
I was wondering if it is possible to write a user defined function that can handle complex coefficients. The specific function I am trying to fit is shown in the attached PDF file. I am looking to fit 6 pole pairs (N=6) where c_p and a_p are the complex coefficients and the asterisk in the superscript represents the complex conjugate. Note that the "j" represents the imaginary number(i.e. square root of -1)
To summarize, the coefficients are eps_inf, c_p, and a_p where c_p and a_p are complex valued. The given data is eps_0, omega, and eps(omega) where eps(omega) is also complex valued.
I am not well versed in Origin C, so any code snippets would be extremely helpful. Thanks.
http://www.originlab.com/ftp/forum_and_kbase/Images/pole_residue_equation.pdf |
|
Shirley_GZ
China
Posts |
|
cjs7
Canada
2 Posts |
Posted - 07/09/2010 : 09:55:12 AM
|
Okay, I understand that. It is straightforward enough. My issue is with the parameters. I notice that when I go to type in my function in the pre-defined Origin C code block, it automatically sets the type of each parameter and variable to double. Is there a way to set the type to complex? |
|
|
shafei
USA
49 Posts |
Posted - 11/18/2010 : 5:45:42 PM
|
I talked to a representative due to the same issue. He mentioned that LabTalk console has issues with handling complex numbers, however, setting datatype in columns to complex, can resolve the problem. So you do not need to separate Real from Imaginary part. The problem is that, I tried couple of things, but couldn't figure out how to set column to complex. |
|
|
greg
USA
1378 Posts |
Posted - 11/24/2010 : 11:05:55 AM
|
Double-click on any column short name to open Column Properties. Change Format to Numeric. Change Data Type to Complex(16). Click OK.
Then type in cell -1.234+5.678i
Here is a script example // BEGIN SCRIPT range ra = 1; // Column 1 ra.type = 1; // Set to Numeric ra.numerictype = 11; // Set to Complex string str; for(idx=1;idx<=50;idx++) { str$ = $(rnd()) + $(rnd())i; ra[idx]$ = %(str$); } // END SCRIPT |
|
|
shafei
USA
49 Posts |
Posted - 11/24/2010 : 11:51:21 AM
|
Thanks Greg, problem resolved. |
|
|
|
Topic |
|
|
|