フィルターのクリア

Indexing problem - how to obtain row and column and use later

3 ビュー (過去 30 日間)
Bran
Bran 2013 年 6 月 25 日
If I have a matrix A = [ 1 2 3; 2 3 4; 2 0 8; 4 8 0; 1 2 0; 0 0 0] and I wanted to store the places where the zeros exist and then use this later to form a new matrix B which equals A but all the zero values are replaced with 4, how would I do this?

採用された回答

Iain
Iain 2013 年 6 月 25 日
whereAequalszero = A ==0;
B = A;
B(whereAequalszero) = 4;

その他の回答 (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