필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by