フィルターのクリア

Matrix manipulation problem under MATLAB

2 ビュー (過去 30 日間)
dakhli mohamed
dakhli mohamed 2018 年 11 月 8 日
コメント済み: dakhli mohamed 2018 年 11 月 8 日
hello I have two matrix the first Swapping={1,1,1; 1,5,1; 2,3,4};
and the second C1={59,57,46 4,39,35 8,22,20} I want to display in a third matrix the values of the second matrix that have the same box with the valeus 1 and 0 besides
result matrix={{59,57,46 4,0,35 0,0,0}

採用された回答

Stephen23
Stephen23 2018 年 11 月 8 日
編集済み: Stephen23 2018 年 11 月 8 日
Storing scalar numerics in cell arrays will make your processing pointlessly complex, so I will presume that you actually sensibly store your numeric data in simpler and more efficient numeric arrays. Then your task is easy:
>> Swapping = [1,1,1;1,5,1;2,3,4]
Swapping =
1 1 1
1 5 1
2 3 4
>> C1 = [59,57,46;4,39,35;8,22,20]
C1 =
59 57 46
4 39 35
8 22 20
>> result = C1 .* (Swapping==1)
result =
59 57 46
4 0 35
0 0 0
  1 件のコメント
dakhli mohamed
dakhli mohamed 2018 年 11 月 8 日
thank you for you Stephen Cobeldick

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by