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 for Programming
 Forum for Origin C
 xatymin function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

ZRA

Germany
8 Posts

Posted - 06/20/2011 :  07:03:35 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: 8.1 SR3
Operating System: WinXP

Hi,

does the XatYmin / XatYmax functions interpolate the x value or do they only lookup in the "data tables" for the lowest y value and return the correspondending x value.

If the functions does not interpolate, which function should i use to return an interpolated curve with a given x interval, to apply the Min/Max function?

Kind regards,
Juergen

ZRA

Germany
8 Posts

Posted - 06/20/2011 :  09:27:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
one additional question:

is there a way to get the coordinates of the minimum value in a 2D-matrix?
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/20/2011 :  7:56:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
XatYMin etc functions are very simple as they need to be fast. You can open internal.c in the system folder to look at them. They do simple table tookups on the XY pairs. You need to do the interpolation first and then use XatYMin on the interpolated data. You can use the interp1 X-Function.

As for matrix, there is no built-in method in the matrixbase class to get the row/col index of Min/Max, but you can first convert the matrix into a vector and then from the vector index to computer the row/col index.

We should certainly improve the GetMax etc method in matrixbase to also allow indices to be returned.


CP

Go to Top of Page

ZRA

Germany
8 Posts

Posted - 06/21/2011 :  06:56:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear CP,

Thank you for your help. But when I try to evaluate the X-function I allways get an error message:

"interp1xy:X-Function failed to execute!
Internal error code: -898, -45"


The code I use is basically the following:

// define xf
					string XF_Name = "interp1xy";
					XFBase xf(XF_Name);
					if(!xf)
					{
						out_str("Fehler beim Interpolieren des Skalierungsfaktors");
						return;
					};
					
					...
					
					// create datasets and fill with result vectors
					Dataset temp_x_1(wks_SkF_1D, 0);
					Dataset temp_y_1(wks_SkF_1D, 1);
					
					temp_x_1 = v_Scaling_Factor;
					temp_y_1 = v_Sum_Residues;
					
					// create DataRange for xf
					DataRange dr_in;
					DataRange dr_out;
					
					// fill DataRange
					dr_in.Add(wks_SkF_1D, 0, "X");
					dr_in.Add(wks_SkF_1D, 1, "Y");
					
					
					dr_out.Add(wks_SkF_1D, 2, "X");
					dr_out.Add(wks_SkF_1D, 3, "Y");
					
					// define xf arguments Max and Min
					double xf_X_min = 0.00;
					double xf_X_max = 1.20;
					
					// number of interpolated points  
					int xf_X_points = 1200;
					
					if( !xf.IsValid() )
   					{
        				out_str("Fehler beim Interpolieren des Skalierungsfaktors");
        				return;
    				}    

										
					// set xf arguments
					if(
						!xf.SetArg(1, dr_in) || 
						!xf.SetArg(8, dr_out) ||
						!xf.SetArg(2, 2) ||
						!xf.SetArg(3, xf_X_points) ||
						!xf.SetArg(4, xf_X_min) ||
						!xf.SetArg(5, xf_X_max))
						{
							out_str("Fehler beim Interpolieren des Skalierungsfaktors");
							return;
						}

								
					// evaluate xf
					if (!xf.Evaluate())
					{
						out_str("Fehler beim Interpolieren des Skalierungsfaktors");
						return;
					}
					

The error occurs in debug mode in the line where I evaluate the x-function. Could you please tell me what the error codes mean and what is wrong with my code?

P.S. At the moment I have only access to Origin 8.0 SR2.
Go to Top of Page

ZRA

Germany
8 Posts

Posted - 06/22/2011 :  10:50:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For thoose who have a similar problem and don't get answer from the Origin support:

The adressing by number seems not to work in the SetArg command. Using the names of the arguments works in the above code.
(eg. "xf.SetArg("iy", dr_in);" instead "xf.SetArg(1, dr_in);")
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 06/22/2011 :  11:49:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry that I didnt find time to try to help sooner, but this forum is not a support forum, as we have user support that you can contact directly the company or your distributors.

It is very good that you found using argument names work fine, as that is a better method anyway. Using numeric will also work but please note that we are in C and thus numbers start from 0, so instead of SetArg(1, dr_in), you should use SetArg(0, dr_in)

CP
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