Substituting particular matrix values
Mostra commenti meno recenti
I have four 512x512 matrices: X1a and X1b, X2a and X2b
I first want to find the coordinates in X1a and X2a where an element equals 255. For this I have been using:
[r,c,v] = find(X1a==255);
a= [r, c, v];
[r,c,v] = find(X2a==255);
b= [r, c, v];
c= [a; b];
Then I want to use ALL the coordinates that I have found (matrix c) to replace the elements in X1a AND X2a with the elements at the same coordinates from X1b and X2b respectively. However- I am unsure how to do this.
Any help would be most appreciated.
Risposte (1)
Andrei Bobrov
il 22 Apr 2014
Modificato: Andrei Bobrov
il 22 Apr 2014
t1 = X1a == 255;
X1a(t1) = X1b(t1);
t2 = X2a == 255;
X2a(t2) = X2b(t2);
or
Xa = cat(3,X1a,X2a);
Xb = cat(3,X1b,X2b);
t = Xa == 255;
Xa(t) = Xb(t);
X1a = Xa(:,:,1);
X2a = Xa(:,:,2);
1 Commento
Charlotte
il 22 Apr 2014
Categorie
Scopri di più su Gaussian Mixture Models in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!