error in resultes of "OR" operator
Show older comments
in the following code I need subtract the values 255 and 254 by 1
and adding the value 0 and 1 by 1 and the other values don't change
X=[255 250 0 100 38 47 150 254
253 251 250 0 0 47 25 252
0 0 0 90 145 74 30 249
200 220 0 1 2 3 225 4
0 255 251 0 4 20 35 245
255 250 0 100 38 47 150 254
200 220 0 1 2 3 225 4
253 251 250 0 0 47 25 252];
Max = 255;
Min = 0;
[x,y] = size(X);
for i= 1:x
for j = 1:y
if X(i,j)==(Max | Max-1)
X1(i,j) = X(i,j)-1;
elseif X(i,j)== (Min | Min+1)
X1(i,j) = X(i,j)+1;
else
X1(i,j)= X(i,j);
end
end
end
**************************************
but resultes not change:it give me
X1=[255 250 0 100 38 47 150 254
253 251 250 0 0 47 25 252
0 0 0 90 145 74 30 249
200 220 0 1 2 3 225 4
0 255 251 0 4 20 35 245
255 250 0 100 38 47 150 254
200 220 0 1 2 3 225 4
253 251 250 0 0 47 25 252];
Please....I need know what error in the code
Accepted Answer
More Answers (1)
Walter Roberson
on 29 Jun 2013
X(i,j)== (Min | Min+1)
means to evaluate the logical condition (Min | Min+1) and then compare that logical result to what is in X(i,j).
Try
if X(i,j) == Min | X(i,j) == Min+1
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!