function - Matlab reshape 函数: number of elements must not change

标签 function matlab reshape

我想通过调用以下自定义函数来使用matlab中的reshape()函数:

imgRgb = reshape(convertYuvToRgb(reshape(imgYuv, height*width, 3)), height, width, 3);

这里:

width=352
height=288

imgYuv是一个4D矩阵。

但是,系统给了我以下错误消息:

To RESHAPE the number of elements must not change.

有高手可以给我一些建议吗?

谢谢!

最佳答案

例如,您无法将 2x4 矩阵 reshape 为 3x3 矩阵。一个有 8 个元素,另一个有 9 个。matlab 发出的警告告诉您已经尝试过类似的操作。

您可能认为矩阵的大小与实际大小不同,但证据就在数字中。检查这些矩阵的实际大小。计算元素。 matlab函数numel会告诉你矩阵中有多少个元素,这样你就可以直接比较。

关于function - Matlab reshape 函数: number of elements must not change,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4041461/

相关文章:

c - 在 C 中表示元胞数组(来自 MATLAB)

reshape - 防止分类变量在列上重复

python - NumPy Array Reshaped 但如何更改轴以进行池化?

javascript - node.js:console.log() 是一个函数吗?

python - 类型为 `name=value` 的 Python 函数参数的名称和原因

java - Java 中的单引号是怎么回事?

python - 在 scipy.io.savemat 中以不同的数值数据格式保存 mat 文件

algorithm - 仅沿数据上边界拟合直线的高效算法

python - 通过调用另一个函数作为子函数来更改函数中的变量值

python - 在 python 中将张量 T[a1,a2,a3] 适当 reshape 为矩阵 M[a2,a1*a3]