# Arduino 二维数组

Ammar Ali 2023年1月30日 2021年4月29日

## Arduino 中的二维数组初始化

``````void setup(){
int nRow = 2;
int nCol = 4;
int myArray[nRow][nCol] = {
{1, 2, 3, 4},
{5, 6, 7, 8}
};
}
``````

## 在 Arduino 中将数据存储到二维数组中

``````void setup(){
int data = 0;
int myArray[nRow][nCol];
for (int nr =0; nr < nRow; nr++) {
for (int nc =0; nc < nCol; nc++) {
myArray[nr][nc] = data++;
}
}
}
``````

## 在 Arduino 中的特定位置替换二维数组中的值

``````void setup(){
int nRow = 2;
int nCol = 4;
int myArray[nRow][nCol] = {
{1, 2, 3, 4},
{5, 6, 7, 8}
};
myArray[nRow][nCol] = 0;
}
``````

## 在 Arduino 中二维数组中的特定位置检索值

``````void setup(){
int nRow = 2;
int nCol = 4;
int myArray[nRow][nCol] = {
{1, 2, 3, 4},
{5, 6, 7, 8}
};
int myValue = myArray[nRow][nCol];
}
``````

## 用于 2D 数组的 Arduino `MatrixMath` 库

Author: Ammar Ali

Hello! I am Ammar Ali, a programmer here to learn from experience, people, and docs, and create interesting and useful programming content. I mostly create content about Python, Matlab, and Microcontrollers like Arduino and PIC.