substituting, indexing two matricies
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have a problem that I hope someone may be able to help me with. I will try to explain it best I can. Essentially i want to substitute values from one matrix into another.
I have matrix A and B and wish to create C
A=[ 2 5 7 ; 6 8 1 ; 3 6 4 ]
B=[ 0 2 0; 4 0 0 ; 8 0 0 ]
C=[ 2 2 7 ; 4 8 1 ; 8 6 4 ]
Matrix C is the same as matrix A except every value except the zeros from matrix B has been substitued into A to create C. I hope I have expleained this properly as I am struggling to find a solution.
I have tried a few methods including loops but have not been able to find a solution.
If anyone is able to help i would be very gratefull. Thanks
Regards Dana
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!