matlab ValueError: could not broadcast input array from shape (8,1) into shape (8,)
时间: 2024-05-15 10:14:56 浏览: 115
This error occurs when you are trying to perform an operation that requires two arrays to have the same shape, but they actually have different shapes. In this case, one array has shape (8,1) and the other has shape (8).
To fix this error, you need to reshape one of the arrays so that it has the same shape as the other. You can use the numpy.reshape function to do this. For example, if you have an array A with shape (8,1), you can reshape it into an array with shape (8,) using the following code:
```
import numpy as np
A = np.reshape(A, (8,))
```
This will reshape the array A to have shape (8,) by collapsing the second dimension. Now you can perform operations with arrays of the same shape without getting the "ValueError: could not broadcast input array from shape (8,1) into shape (8,)" error.
阅读全文