필터 지우기
필터 지우기

Copying index positions to other matrices

조회 수: 1 (최근 30일)
Zaharaddeen Hussaini
Zaharaddeen Hussaini 2019년 5월 16일
댓글: madhan ravi 2019년 5월 16일
Hi, I am trying to equate the index postion of a matrix onto other matrices. This what I did and the results do not seem to be correct
A = rand(10,10); % First Random Matrix
A2 = rand(10,10); % Second Random Matrix
M = mean2(A); %Mean Value of A
B = A; %Copy
B(B<M) = NaN;
[row, col] = find(isnan(B)); %NaN Index Position of B
B2 = A2;
B2([row, col])=NaN %Copy of NaN Index Position onto array B2
Now unfortuntely it does not seem to transfer the index position of B onto array B2.
Thanks

채택된 답변

madhan ravi
madhan ravi 2019년 5월 16일
편집: madhan ravi 2019년 5월 16일
B2(sub2ind(size(B),row,column))=NaN
Why not directly use logical indexing from isnan() ?
  댓글 수: 5
Jan
Jan 2019년 5월 16일
This means:
mask = (B < M);
B(mask) = NaN;
B2 = A2;
B2(isnan(B)) = NaN;
madhan ravi
madhan ravi 2019년 5월 16일
@Jan: Bedank' mich :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by