changing the structure of a matrix according to a characteristic matrix

1 次查看(过去 30 天)
I have a matrix (I am calling it characteristic):
=
0 1 1
0 0 1
1 1 1
and another one (which has to be changed):
b =
9 8 7
3 2 7
4 5 3
What I want is to make certain operation on b to remove elements that are in the position of 0 in matrix .
=
0 8 7
0 0 7
4 5 3
Any idea how to do it?

采纳的回答

Sudhakar Shinde
Sudhakar Shinde 2020-10-22
编辑:Sudhakar Shinde 2020-10-22
Use elementwise (.) operator :
Xa=[0 1 1;0 0 1;1 1 1]
b=[9 8 7;3 2 7;4 5 3]
b.*Xa

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by