Why am I not getting the expected result?
Show older comments
I have the function listed at the bottom of this post which is supposed to return a matrix that has the same size of a matrix `x` with pixels that had a degree of membership `y`=1 to `1` and the other pixels to `0`.
But, when I ran the function I didn't get the expected results as follows (why is that?):
>> x = [1 4 3; 6 4 3; 6 9 3; 2 4 3; 5 4 0; 5 3 1; 6 4 7];
>> y = [0 0 1; 1 1 0; 1 1 0; 0 1 1; 0.2 0.8 0.54; 1 1 1; 0 0 0];
>> pixel_val(x,y)
ans =
0 0 0
0 0 0
0 0 0
0 0 0
0 0 0
1 1 1
0 0 0
function c = pixel_val(x, y)
[ii,jj]=find(y==1);
x(ii,jj)=1;
[ii2,jj2] = find (y~=1);
x(ii2,jj2)=0;
c = x;
end
Thanks.
Accepted Answer
More Answers (1)
Walter Roberson
on 23 Feb 2013
0 votes
It was explained for you already. Read http://www.mathworks.co.uk/matlabcentral/answers/64472-one-function-returns-the-correct-results-the-opposite-not-why#answer_76075
Categories
Find more on Grid Lines, Tick Values, and Labels 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!