Scale2D
- Updated2023-02-21
- 2 minute(s) read
Advanced Analysis Library Only
AnalysisLibErrType Scale2D (void *inputArray, ssize_t numberOfRows, ssize_t numberOfColumns, void *outputArray, double *offsetValue, double *scalingFactor);
Purpose
Scales the input array and returns the scale and offset constants. The scaled output array is in the range [–1 : 1]. Scale2D can obtain the (i, j)th element of the scaled array using the following formulas:


offset = min + scale
where max and min are the maximum and minimum values in the input array, respectively.
You can use LinEv2D to reconstruct the input array using the scale and offset constants. Scale2D can perform the operation in place; that is, the input and output arrays can be the same.
The following uses the Scale2D function.
double inputData[10][10], scaledData[10][10];
double offset, scalingFactor;
int i, j, numRows, numCols;
AnalysisLibErrType status;
numRows = 10;
numCols = 10;
/* Use a For loop to generate a 2D array of random numbers between 0.0 and 1.0 */
for (j = 0; j < 10; j++)
for (i = 0; i < 10; i++)
inputData[i][j] = Random(0.0, 1.0);
/* Scale inputData and return offset and scaling factor */
status = Scale2D(inputData, numRows, numCols, scaledData, &offset, &scalingFactor);
Parameters
Input | ||
Name | Type | Description |
inputArray | void * | Input array used as the basis for the scaling operation. This matrix must be an array of doubles. |
numberOfRows | ssize_t | Number of rows used in the scaling operation. |
numberOfColumns | ssize_t | Number of columns used in the scaling operation. |
Output | ||
Name | Type | Description |
outputArray | void * | Scaled array, as an array of doubles. |
offsetValue | double | Offsetting constant of the input array. |
scalingFactor | double | Scaling constant of the input array. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later