MATLAB Answers

0

I want to change matrix value

Asked by Abdullah on 3 Mar 2017
Latest activity Commented on by Adam
on 8 Mar 2017
I have image in V channel, I want to do like that IF the matirx element == this value then ignore else change the value of that pixel or number to this number then store it in new matrix How can I do that ?

  0 Comments

Sign in to comment.

2 Answers

Answer by KSSV
on 3 Mar 2017

K = round(rand(3,3)) ;
K0 = K
% change equal to one's to -1
K(K==1) = -1

  2 Comments

thanks for your reply but my issue is like that I have image matrix example
A = 1 2 3 4 5 6 7 8 9 1 3 5 B = 1:3 if A==B change the value of that pixel to 0 else just leave it save the new A in A_new
that what i need to do
To check for A==B both of them should be of same dimension. In your example, they are different.

Sign in to comment.


Answer by Adam
on 3 Mar 2017
Edited by Adam
on 3 Mar 2017

myArray( myArray ~= someValue ) = someOtherValue;

  2 Comments

thanks for your reply but my issue is like that I have image matrix example
A = 1 2 3 4 5 6 7 8 9 1 3 5 B = 1:3 if A==B change the value of that pixel to 0 else just leave it save the new A in A_new
that what I need to do
A( ismember( A, B ) ) = 0;

Sign in to comment.