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
 Nonlinear curve fitting with complex coefficients
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cjs7

Canada
2 Posts

Posted - 07/08/2010 :  11:26:45 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Posted - 07/09/2010 :  04:16:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi cjs7,

To fit with a complex function, you should separate the complex function to two functions firstly: one corresponding to its real part and the other corresponding to its imaginary part.

See the example here, http://www.originlab.com/www/helponline/origin/en/mergedProjects/Tutorial/Tutorial/Fitting_Complex_Function.html

Thanks,
Shirley

Originlab Technical Service Team
Go to Top of Page

cjs7

Canada
2 Posts

Posted - 07/09/2010 :  09:55:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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?
Go to Top of Page

shafei

USA
49 Posts

Posted - 11/18/2010 :  5:45:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

greg

USA
1378 Posts

Posted - 11/24/2010 :  11:05:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

shafei

USA
49 Posts

Posted - 11/24/2010 :  11:51:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Greg, problem resolved.
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