MaxMin1D是NI Labwindows CVI開發環境中的一個系統函式,通過該函式可以獲取一維數組的最大值、最小值以及最大值和最小值在數組中的序號。
基本介紹
- 中文名:獲取一維數組最大值和最小值
- 外文名:MaxMin1D
概要,參數,返回值,其它信息,
概要
MaxMin1D函式返回輸入數組中的最大值和最小值,以及最大值和最小值所在的位置,如果出現多個相等的最大值和最小值,MaxMin1D返回第一個值所在的位置,如果數組中所有元素值為NaNs(NotANumber,不是一個數),MaxMin1D返回最大值和最小值的索引(位置)為-1。
Finds the maximum and minimum values in the input array and their locations in the array. If there are multiple instances of the maximum and/or minimum values, MaxMin1D returns the location of the first occurrence. If all the elements in the input array are NaNs, MaxMin1D returns -1 for both the index of the maximum value and the index of the minimum value.
參考事例如下:
double inputData[10];
double maximumValue, minimumValue;
int maximumIndex, minimumIndex;
AnalysisLibErrType status;
// Generate an array of random numbers
status = Uniform (10, 17, inputData);
status = MaxMin1D(inputData, 10, &maximumValue, &maximumIndex, &minimumValue, &minimumIndex);
參數
Input/輸入參數 | ||
Name/名稱 | Type/類型 | Description/描述 |
inputArray/輸入數組 | double [] | The array from which the maximum and minimum values and their locations within the array are determined. |
numberOfElements/元素個數 | ssize_t | Number of elements used in determining the maximum and minimum values. |
Output/輸出參數 | ||
Name/名稱 | Type | Description |
maximumValue/最大值 | double | Maximum value found in the input array. |
maximumIndex/最大值索引(位置) | ssize_t | The index of the maximum value found in the input array. |
minimumValue/最小值 | double | Minimum value found in the input array. |
minimumIndex/最小值索引(位置) | ssize_t | The index of the minimum value found in the input array. |
返回值
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
其它信息
使用MaxMin1D函式需添加如下頭檔案,系統會在編譯的時候詢問是否添加,所以該步驟可以省略!
Library: Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later