BOOL SetData( vector<complex> * pvY, vector * pvX, int nIndex = 0, DWORD dwDRSOpts = DRS_SET_COL_DESIGNATIONS )
BOOL SetData( vector * pvYReal, vector * pvYImag, vector * pvX, int nIndex = 0, DWORD dwDRSOpts = DRS_SET_COL_DESIGNATIONS )
TRUE if success, FALSE if fail.
EX1
// The function first creates a worksheet for output, adds // columns as necessary according to the total number of desired // data (nNumData), and initializes the output XYRangeComplex object. // Then it generates some complex data and puts them into the XYRangeComplex // using XYRangeComplex::SetData(). void test_XYRangeComplex_SetData(int nNumData = 1) { Worksheet wksOut; wksOut.Create(); // Make sure the worksheet has 2 * nNumData columns (X, Ycomplex for each data): while ( wksOut.Columns.Count() < 2 * nNumData ) wksOut.AddCol(); ///////////////// // Initialize XYRange for setting the data into: XYRangeComplex dr; for (int idata = 0; idata < nNumData; idata++) { dr.Add("X", wksOut, 0, 2 * idata, -1, 2 * idata); // Set the destination column for complex: Column colObj = wksOut.Columns(2 * idata + 1); colObj.SetFormat(OKCOLTYPE_NUMERIC); colObj.SetInternalData(FSI_COMPLEX); dr.Add("Y", wksOut, 0, 2 * idata + 1, -1, 2 * idata + 1); dr.Add("S", NULL); } // Generate some data and set it into the XYRange: int nNumRows = 5; for (idata = 0; idata < nNumData; idata++) { vector<complex> vc; vector vx; vc.SetSize(nNumRows); vx.SetSize(nNumRows); for (int row = 0; row < nNumRows; row++) { double rX = (idata + 1) * (row + 1); double rReal = pow(10, idata) + (row + 1); double rImag = 2 * pow(10, idata) + (row + 1) * (row + 1); complex cc(rReal, rImag); vc[row] = cc; vx[row] = rX; } if ( !dr.SetData(&vc, &vx, idata) ) { out_str("Failed to set data."); } } }
EX2
// The function first creates a worksheet for output, adds // columns as necessary according to the total number of desired // data (nNumData), and initializes the output XYRangeComplex object. // Then it generates some complex data and puts them into the XYRangeComplex // using XYRangeComplex::SetData(). void test_XYRange_SetComplexData_2(int nNumData = 1) { Worksheet wksOut; wksOut.Create(); // Make sure the worksheet has 2 * nNumData columns (X, Ycomplex for each data): while( wksOut.Columns.Count() < 2 * nNumData ) wksOut.AddCol(); ///////////////// // Initialize XYRange for setting the data into: XYRangeComplex dr; for( int idata = 0; idata < nNumData; idata++ ) { dr.Add("X", wksOut, 0, 2 * idata, -1, 2 * idata); // Set the destination column for complex: Column colObj = wksOut.Columns(2 * idata + 1); colObj.SetFormat(OKCOLTYPE_NUMERIC); colObj.SetInternalData(FSI_COMPLEX); dr.Add("Y", wksOut, 0, 2 * idata + 1, -1, 2 * idata + 1); dr.Add("S", NULL); } // Generate some data and set it into the XYRange: int nNumRows = 5; for (idata = 0; idata < nNumData; idata++) { vector vReal; vector vImag; vector vx; vReal.SetSize(nNumRows); vImag.SetSize(nNumRows); vx.SetSize(nNumRows); for (int row = 0; row < nNumRows; row++) { double rX = (idata + 1) * (row + 1); double rReal = pow(10, idata) + (row + 1); double rImag = 2 * pow(10, idata) + (row + 1) * (row + 1); vReal[row] = rReal; vImag[row] = rImag; vx[row] = rX; } if ( !dr.SetData(&vReal, &vImag, &vx, idata) ) { out_str("Failed to set data."); } } }
XYRangeComplex::GetData, DataRange::GetData, DataRange::SetData
origin.h