简体   繁体   English

在分配A(I)= B中,B和I中的元素数必须相同

[英]In an assignment A(I) = B, the number of elements in B and I must be the same

When running this code: 运行此代码时:

A(B<5) = C + (B-5)*5/10;

I'm getting the following error 我收到以下错误

In an assignment A(I) = B, the number of elements in B and I must be the same

Where A , B and C are large matrices of same size (6399x6926). 其中ABC是大小相同(6399x6926)的大型矩阵。 I could get it to work using a for loop, but it took more time. 我可以使用for循环使它工作,但是花费了更多时间。

The problem is that size of A(B<5) will typically be smaller then size of A . 问题在于A(B<5)大小通常会小于A大小。 Size of A(B<5) will be equal to the number of elements of B that obey condition B<5 . A(B<5)将等于B满足条件B<5的元素的数量。

Example: 例:

B=[0 3 8 10]
A=[1 2 3 4]

A(B<5)=[1 2]

This is because only first two elements are less then 5. 这是因为只有前两个元素少于5。

Possibly, you wanted to do this: 您可能想这样做:

A(B<5) = C(B<5) + (B(B<5)-5)*5/10;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 赋值A(I)= B时出错,B和I中的元素数必须相同 - error with an assignment A(I) = B, the number of elements in B and I must be the same 在赋值A(I)= B中,B和I中的元素数必须相同 - In an assignment A(I) = B, the number of elements in B and I must be the same 在分配A(I)= B中,B和I中的元素数必须相同 - In assignment A(I) = B, the number of elements in B and I must be the same 马赛克:??? 在赋值 A(I) = B 中,B 和 I 中的元素个数必须相同 - MATLAB: ??? In an assignment A(I) = B, the number of elements in B and I must be the same 在赋值 A(:) = B 中,A 和 B 中的元素数量必须相同 - In an assignment A(:) = B, the number of elements in A and B must be the same 在赋值 A(:) = B 中,A 和 B 中的元素数量必须相同 - In an assignment A(:) = B, the number of elements in A and B must be the same 逻辑数组 - 在赋值A(I)= B中,B和I中的元素数必须相同 - Logical Arrays - In an assignment A(I) = B, the number of elements in B and I must be the same 不知道如何纠正:“在赋值A(I)= B中,B和I中的元素数必须相同。” - Don't know how to Correct : “In an assignment A(I) = B, the number of elements in B and I must be the same.” 如何解决:在分配A(I)= B中,B和I中的元素数必须相同 - How to solve: In an assignment A(I) = B, the number of elements in B and I must be the same 需要详细解释“在赋值A(I)= B中,B和I中的元素数必须相同” - Need detail explaination about “In an assignment A(I) = B, the number of elements in B and I must be the same”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM