Minimum Origin Version Required: Origin 8 SR0
This example shows how to access NAG continuous wavelet transformation routines to calculate the wavelet coefficients.
#include <oc_nag.h> #include <nag\OC_nag_ex.h> void cwt_ex() { // pick input data from worksheet for CWT calculation Worksheet wks = Project.ActiveLayer(); if( !wks || wks.GetNumCols() < 2 ) { printf("Please make sure a worksheet is active with two columns.\n"); return; } Dataset dsSignal(wks, 0); // assume that the first column is signal data Dataset dsScale(wks, 1); // the second column is scale data int nSignal = dsSignal.GetSize(); int nScale = dsScale.GetSize(); // copy the data from columns to vectors vector vSignal(nSignal); vector<int> vnScale(nScale); vSignal = dsSignal; vnScale = dsScale; // prepare the parameters for NAG cwt routine // types of wavelet can be used: Nag_Morlet, Nag_DGauss, Nag_MexHat Nag_WavType nagType = Nag_Morlet; int nWavePara = 5; static NagError fail; matrix mat(nScale, nSignal); nag_cwt_real(nagType, nWavePara, nSignal, vSignal, nScale, vnScale, mat, &fail); if(fail.code != NE_NOERROR) //examine error if there is { printf("%s\n",fail.message); } // prepare the output matrixbook for the matrix coefficient MatrixLayer ml; ml.Create("Origin"); // create new matrix layer with default template named "Origin" // set the number of rows and columns and XY range for matrix window MatrixObject mo = ml.MatrixObjects(0); mo.SetSize(nScale, nSignal); mo.SetXY(0, 0, nSignal - 1, nScale - 1); // copy result from mat variable to the matrix window matrix& matData = mo.GetDataObject(); matData = mat; }