Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Dual Sine Graph

Hey, I was wondering how do you change the amplitude and the amount of cycles in a Dual Sine Graph. The Dual Sine Graph code is:

// Graph the dual sine graph
// Declare variables and constant
const int SIZE = 41;
double xData[SIZE];
double yData[SIZE];
double zData[SIZE][SIZE];

// Use a for loop to go through each array point
// and store in a number that results from the equation
for (int i = 0; i < 41; i++)
{
xData[i] = (i - 20.0)/20.0 * PI;
yData[i] = (i - 20.0)/20.0 * PI;
}

// Use two for loops to go through each matrix point of zData
// and store in the results from an equation
for (i = 0; i < 41; i++)
{
for (int j = 0; j < 41; j++)
{
zData[j][i] = sin(xData[i])*cos(yData[j]);
}
}

// Convert the native C++ double
arrays to NI data types for visualization.
CNiReal64Vector xVector(SIZE, xData);
CNiReal64Vector yVector(SIZE, yData);
CNiReal64Matrix zMatrix(SIZE, SIZE, *zData);

// Plot the data
m_c3DGraph.Plot3DSurface(xVector, yVector, zMatrix);


I am wondering in which part of the code can you change the amplitude and how do you change the amplitude. I am also wondering in which part of the graph can you change the period of the graph and the amount of cycles. Thanks.
0 Kudos
Message 1 of 2
(2,897 Views)
Take a look at the CNiMath::SineWave method. It has parameters that will let you specify phase, amplitude, frequency, and number of samples. Note, however, that the CNiMath methods work with CNiReal64Vector and not with C++ double array types.

- Elton
0 Kudos
Message 2 of 2
(2,897 Views)