フィルターのクリア

how to index zeros or remove zeros for indexing?

2 ビュー (過去 30 日間)
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar 2018 年 10 月 11 日
回答済み: Bruno Luong 2018 年 10 月 11 日
if
if true
% code
A=[1 2 3 0 0 4]
B=[1 3 5 2 4 5]
C=[1 56 65 65 65; 4 5 45 546 4; 54 54 51 21 21; 4 453 3645 534 4; 54 554 54 541 1]
D= C(A,B)
end
i want D to be zero when A is zero but it shows indexing is not valid

採用された回答

Bruno Luong
Bruno Luong 2018 年 10 月 11 日
D=zeros(length(A),length(B))
D(A>0,B>0)=C(A(A>0),B(B>0))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by