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
 Graphing Equations
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AndiChoin

USA
Posts

Posted - 07/12/2004 :  8:19:31 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
What is the best way to use Origin to graph a long, complicated equation? NLSF - User Defined, in Origin C code or in the Function button on a graph? I have an equation that is very long (over 2,750 characters with about 15 parameters, but only one depedndant and one independent variable) and I am having trouble getting it to make the correct predicted curve in NLSF. It gives different results based on whether I choose Origin C, Y-script, or Equations, even thorugh if Origin C is clicked it compiles fine. I am greatly confused by this. Is the equation too long? If so, how can I break it up and feed the results into the main equation?

Sorry, I just started using Origin and I am still trying to get a handle on it.

-Andi

hajo_old

Germany
141 Posts

Posted - 07/13/2004 :  03:17:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello, Andi

Do you have the possibility to use a real math package like MatLab or SciLab (it's free available from INRIA) to calculate the equation and have a first look at the graph? If you know the right result it is more effective to look for a sollution in Origin (OC or Labtalk).

Generally you'll have to generate the X and Y chanal in an Origin Worksheet as data (-point) base before the creation of the graph. Therfore you also could use an external specialized package.

quote:
Is the equation too long?


Where did you enter the equation? How did you calc the OriginC code ... Can we have some more details please? Maybe there's an error between your LabTalk and OriginC code, so you get different results ... Can you breake up the function in several steps you can easily control?

So far, hope that helps for examining the problem ...


-- --
Dipl.-Ing. Hans-Joerg Koch
SiemensVDO Automotive
Regensburg


Edited by - hajo on 07/13/2004 03:18:01 AM
Go to Top of Page

easwar

USA
1964 Posts

Posted - 07/13/2004 :  09:28:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Andi,

I would suggest creating an Origin C file with a function in it that defines your equation. Once you do that, you can make that file as part of your system folder so that this function becomes available to you in all Origin sessions. An easy way to do this is to create a new OC file in Code Builder, then add your function definition to it, and then add the file to the System folder of the Code Builder workspace tree.

Once the above is done, your function will be available for use from multiple places such as script window, set column values dialog for columns etc. And you can then define a new fitting function in NLSF that just calls this OC function. The new fitting function can then simply be defined using the type Y-Script.

First step is to make sure your function returns correct values. As Hajo suggested, once you create the OC function, you can try set column values to generate X,Y datasets and graph them and see if the function is generating correct values.

If you run into problems creating the OC file as described above, and/or your function is not generating correct values, send the function code to tech@originlab.com and mention this forum post, for further help.

Easwar
OriginLab

Go to Top of Page

AndiChoin

USA
Posts

Posted - 07/13/2004 :  2:08:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I know the result that I am looking for. I did the equation out as a series of calculated points in MS Excel and put the points on the same graph as the generated lines. The points did not match any of the lines. I think it would be better if I broke it up into smaller parts, but I don't know how.

I tried using the Origin C Code Builder within the NLSF dialog (a created a user defined function and saved it) by breaking the long equation into a series of smaller ones such as:

double tao;
double den;
double phi;
double diE;
double Qu;
double ZZeff;
tao = 1-(x/647.096);
den = a function of tao;
phi = tao^(1/3);
diE = a function of phi;
Qu = (3*P1^2 - 5*P1 +2)/8;
ZZeff = a function of several parameters and den and Qu;
y = a function of several parameters and den, diE, ZZeff, and x;

It compiles fine in the code builder. I enter in the parameter values on the simulate curve button and click create curve. It creates a curve that is not correct. I have checked the equations many times and had a colleague check them as well (there are a large number of parenthesis-gets a little confusing), but both of us agree that the equations are written correctly. Is there something that I am missing?

-Andi

P.S. I did not write out the functions as they are a little long, but if you think that the problem is just that they are typed incorrectly, I will be happy to post them.
Go to Top of Page

AndiChoin

USA
Posts

Posted - 07/13/2004 :  2:19:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Also, Is there online help on using/writing Origin C? I have tried reading the book that came with the program and found it very uninformative. Also, Do I need to download the help files for programming seperatelly? They do not come up when I click Help>>Progaming.

-Andi
Go to Top of Page

Mike

USA
357 Posts

Posted - 07/13/2004 :  2:58:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Andi, about your Programming Help file problem: When you select Help:Programming you should either get the Programming Help file or an attention message telling you to select the Help:Check for Updates menu item. Check for Updates queries our FTP site for software updates (including Help file updates).

During program installation, the user can decline installation of the Help files (and a couple of other things such as the NAG PDF files), so that must be why you do not have the programming Help files. When you run Help:Check for Updates, you should see 8 Programming Help files (1 master + 7 others). You will want to get all of them.

If you using Origin 7, you can get the Help files here.

Mike
OriginLab

Edited by - Mike on 07/13/2004 3:09:13 PM
Go to Top of Page

easwar

USA
1964 Posts

Posted - 07/13/2004 :  3:08:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Andi,

The problem can be ask simple as in statements such as:
phi = tao^(1/3);

Note that Origin C follow C programming syntax, and so 1/3 is zero, not 0.3333 since it is integer division and not real number division. With statements such as these, you should instead write:
phi = tao^(1.0/3);
so that at least one number in the expression is double, and then the result would be double.

I suspect this is the problem. There may be more than one place where this occurs. If correcting this does not fix the problem, please send your function file to tech@originlab.com or cut and paste here.

Easwar
OriginLab


Go to Top of Page

AndiChoin

USA
Posts

Posted - 07/13/2004 :  5:09:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike-

Thank you. I think that something went wrong in the install process, likely my fault, as the files were installed on my computer but only had a size of 1KB. This is probably why the message to install them under check for updates did not come up. I appriciate the link. I have installed them, and they are very useful.

Easwar-

That has helped. I figured that it was just some stupid little thing that I was doing wrong as I am not yet familiar with the program and the syntax used therein. The answers are much more correct, but I think I may still have a few bugs to work out. I'll give it a few more goes before I resort to posting the entire thing and asking you to fix it.

-Andi
Go to Top of Page

AndiChoin

USA
Posts

Posted - 07/13/2004 :  5:29:20 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Easwar-

Yep, I got it. Thank you so very much for your help and patience.

-Andi
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