replace the elements of a matrix
显示 更早的评论
Hello,
Consider a 100x1 matrix, called A, that contains random values of "0" and "1".
The number of "1" is 25 and the rest 75 are "0".
Also, consider a matrix 25x1, called B, that contains random values.
How can I replace the "1" of matrix A with the values of matrix B?
The "0" of A would not be influenced.
Thank you.
Best,
Pavlos
采纳的回答
更多回答(1 个)
Dishant Arora
2014-2-13
A(find(A==1))=B;
2 个评论
Azzi Abdelmalek
2014-2-13
Why to add find when you can do it without it?
Dishant Arora
2014-2-13
yeah,got it
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!