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 for Programming
 Forum for Origin C
 xatymin function

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
ZRA Posted - 06/20/2011 : 07:03:35 AM
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
5   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 06/22/2011 : 11:49:36 AM
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
ZRA Posted - 06/22/2011 : 10:50:11 AM
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);")
ZRA Posted - 06/21/2011 : 06:56:51 AM
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.
cpyang Posted - 06/20/2011 : 7:56:49 PM
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

ZRA Posted - 06/20/2011 : 09:27:40 AM
one additional question:

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

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