<?xml version="1.0"?>
<OriginStorage FileName="D:\OriginPro80\Samples\Programming Guide\X-Functions\get_matrix_stats_ex.OXF" Display="652" Label="System: get_matrix_stats_ex"><XFname NodeID="11" Label="Name" DataID="300">get_matrix_stats_ex</XFname><xFdescription NodeID="11" Label="Description" DataID="310">create XYZ worksheet from matrix using regular convertion</xFdescription><attachTo NodeID="13" Label="Attach to Origin Object" Combo="None|Auto|Column|Sheet/Layer|Book/Graph" DataID="320">1</attachTo><UsageCtxt NodeID="268435456" Label="Usage Context" DataID="329"><LabTalk NodeID="10" Label="Labtalk" DataID="357">1</LabTalk><WksSel NodeID="10" Label="Worksheet Selection" DataID="350">0</WksSel><WksSel NodeID="10" Label="Worksheet Selection Change" DataID="355">0</WksSel><WksSel NodeID="10" Label="Worksheet Selection Tracking" DataID="356">0</WksSel><GrObj NodeID="268435456" Label="Graphic Object Events" DataID="330" Use="0"><InitAnchors NodeID="10" Label="Initialization" DataID="339">1</InitAnchors><Move NodeID="10" Label="Move" DataID="331">1</Move><Moving NodeID="10" Label="Moving" DataID="332">0</Moving><Resize NodeID="10" Label="Resize" DataID="333">0</Resize><Resizing NodeID="10" Label="Resizing" DataID="334">0</Resizing><Delete NodeID="10" Label="Delete" DataID="335">0</Delete><Select NodeID="10" Label="Select" DataID="336">0</Select><Unselect NodeID="10" Label="Unselect" DataID="337">0</Unselect><BtnClick NodeID="10" Label="Button Click" DataID="338">0</BtnClick><Rotate NodeID="10" Label="Rotate" DataID="340">0.</Rotate><Rotating NodeID="10" Label="Rotating" DataID="341">0.</Rotating><Skew NodeID="10" Label="Skew" DataID="342">0.</Skew><Skewing NodeID="10" Label="Skewing" DataID="343">0.</Skewing><EditEv NodeID="10" Label="Edit" DataID="344">0.</EditEv><Editing NodeID="10" Label="Editing" DataID="345">0.</Editing></GrObj><ToXFHeader NodeID="10" Label="Declare in xf.h" DataID="358">0</ToXFHeader></UsageCtxt><vars NodeID="268435456" Label="Variables" Branch="1" MoveRows="" EditCol="1|1|1"><v1 NodeID="268435456" _XFUNCTION_VAR="1" RepeatID="1" Branch="1"><name NodeID="11" Label="Name" DataID="10">mo</name><description NodeID="11" Label="Description" DataID="20"></description><io NodeID="13" Label="Input/Output" Combo="Input|Output|Input/Output" DataID="30" Handler="116810768">0</io><type NodeID="11" Label="Data Type" Combo="double|string|int|vector|Range|XYRange|XYZRange|matrix|MatrixObject|ButtonInfo|LineInfo|TextInfo|EventInfo|MarkerInfo" DataID="40" Handler="116810768">MatrixObject</type><valdata NodeID="35" Label="Data" DataID="50">&lt;active&gt;</valdata><Context NodeID="268435456" Label="Context"/><Data NodeID="268435456" Label="New Output Data" DataID="911" Branch="2048" Show="0"><Book NodeID="11" Label="Book" Combo="&lt;active&gt;|&lt;new&gt;|&lt;source&gt;|&lt;existing&gt;..." DataID="903" Handler="116145272">&lt;active&gt;</Book><Sheet NodeID="11" Label="Sheet" Combo="&lt;active&gt;|&lt;new&gt;|&lt;existing&gt;..." DataID="904" Handler="113838192" Enable="1">&lt;active&gt;</Sheet><ColumnName NodeID="11" Label="Column" DataID="912">Default</ColumnName><XColumnName NodeID="11" Label="XColumn" DataID="913">X</XColumnName><YColumnName NodeID="11" Label="YColumn" DataID="914">Y</YColumnName><ZColumnName NodeID="11" Label="ZColumn" DataID="915">Z</ZColumnName></Data></v1></vars><header NodeID="45" Label="Header" DataID="323" RowHeightRange="3-15"><![CDATA[#include <origin.h>
]]></header><code NodeID="45" Label="Expression" DataID="325" RowHeightRange="5-20"><![CDATA[// Use input MatrixObject to Get XY coordinates, rows, and columns
if( mo.IsValid() )
{
	double xmin, ymin, xmax, ymax;
	mo.GetXY(xmin, ymin, xmax, ymax); 
	int nRows = mo.GetNumRows();
	int nCols = mo.GetNumCols();
	
	// Use input MatrixObject to get data object (i.e. matrix)
	matrixbase& mb = mo.GetDataObject(); // Get matrix as matrixbase because it has no assumed base data type
	matrix mTemp; // We are not sure if input matrix is double so make copy and cast 
	mTemp = mb; // Cast matrixbase to matrix of doubles
	LT_execute("type -a"); // Open Script Window
	printf("\n%s\n-----------------\nmean = %g\nmedian = %g\nz min = %g\nz max = %g\n" + 
		"x min = %g\nx max = %g\ny min = %g\ny max = %g\nrows = %d\ncols = %d\n",
		mo.GetName(), mTemp.GetMean(), mTemp.GetMedian(), mTemp.GetMin(),	mTemp.GetMax(),
		xmin, xmax, ymin, ymax, nRows, nCols);
}]]></code></OriginStorage>
