matlab zeros()
时间: 2023-08-23 07:09:44 浏览: 37
Matlab's `zeros()` function is used to create an array filled with zeros. It takes one or more arguments to specify the size of the array.
Here's the syntax:
```matlab
A = zeros(m,n)
```
where `m` specifies the number of rows and `n` specifies the number of columns in the resulting array `A`.
For example, if you want to create a 3x4 array filled with zeros, you can use:
```matlab
A = zeros(3,4)
```
This will give you the following array:
```
A =
0 0 0 0
0 0 0 0
0 0 0 0
```
You can also create higher-dimensional arrays by specifying additional arguments. For instance, to create a 2x2x3 array filled with zeros, you can use:
```matlab
B = zeros(2,2,3)
```
This will give you the following array:
```
B(:,:,1) =
0 0
0 0
B(:,:,2) =
0 0
0 0
B(:,:,3) =
0 0
0 0
```
The `zeros()` function is useful for initializing arrays before assigning values to them or for creating arrays with specific dimensions.