运行此代码时:
A(B<5) = C + (B-5)*5/10;我得到了以下错误
In an assignment A(I) = B, the number of elements in B and I must be the same其中A、B和C是大小相同的矩阵(6399x6926)。我可以使用for循环让它工作,但它需要更多的时间。
发布于 2015-03-13 07:12:46
问题是A(B<5)的大小通常会小于A的大小。A(B<5)的大小将等于符合条件B<5的B元素的数量。
示例:
B=[0 3 8 10]
A=[1 2 3 4]
A(B<5)=[1 2]这是因为只有前两个元素小于5。
您可能想要这样做:
A(B<5) = C(B<5) + (B(B<5)-5)*5/10;https://stackoverflow.com/questions/29020395
复制相似问题