Two matrices comparison

1 次查看(过去 30 天)
Claire Redfield
Claire Redfield 2012-6-16
%I have two matrices, a=[1 2 3]; b=[0 1 0]; %How can i get a1=a if b=1 and a1=0 if b=0, So that a1=[0 2 0]?Thanks!

采纳的回答

Ellen
Ellen 2012-6-16
a1=a.*b;
the dot before the multiplication sign makes sure the multiplication is done elment by element, so a1(1)=a(1)*b(1)......

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by