Copying index positions to other matrices

1 Ansicht (letzte 30 Tage)
Zaharaddeen Hussaini
Zaharaddeen Hussaini am 16 Mai 2019
Kommentiert: madhan ravi am 16 Mai 2019
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

Akzeptierte Antwort

madhan ravi
madhan ravi am 16 Mai 2019
Bearbeitet: madhan ravi am 16 Mai 2019
B2(sub2ind(size(B),row,column))=NaN
Why not directly use logical indexing from isnan() ?
  5 Kommentare
Jan
Jan am 16 Mai 2019
This means:
mask = (B < M);
B(mask) = NaN;
B2 = A2;
B2(isnan(B)) = NaN;
madhan ravi
madhan ravi am 16 Mai 2019
@Jan: Bedank' mich :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by