add a constant value for all columns for selected rows
18 次查看(过去 30 天)
显示 更早的评论
Hi,
I need to add a constant value (7000) to a selected rows as identified by the logical array index. But, I want to perform something like shown in the example below.
Example:
A =
1010001 10 20 30 40 50 60
1010002 100 200 300 400 500 600
1010003 5 6 7 8 9 10
1010004 1 2 3 4 5 6
B =
1010002
1010004
Output =
1010001 10 20 30 40 50 60
1010002 7100 7200 7300 7400 7500 7600
1010003 5 6 7 8 9 10
1010004 7001 7002 7003 7004 7005 7006
I have a code as shown below BUT this does NOT produce the output I want like in C
i1z=ismember(A(:,1),B);
A=A(i1z,:)+7000;
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!