## One function returns the correct results, the opposite not. Why?

## One function returns the correct results, the opposite not. Why?

(OP)

I have the following function that checks the pixels from `x` that have the membership value `near 1` and sets those pixels in `x` to `1` and return them back. The works pretty well for me:

function c = core(x, y)

tolerance = 0.01;

[ii,jj]=find (abs(y)-1 <= tolerance);

x(ii,jj)=1; % set pixels in x with y=1 to 1

idx=[ii,jj]; % indexes of pixels with y=1

c=x(abs(y)-1 <= tolerance); % values of pixels

end

Now, to the opposite function below. I just want to check the pixels that have membership values values `not equal to one` and since in my case I don't have exactly value `1` and this used `tolerance`. I wrote what I think is the opposite of the above, but my output is an `empty matrix`. Why is that? What should I change in the function below?

function s = support(x, y)

tolerance = 0.01;

[ii,jj]= find (abs(y)-1 > tolerance);

x(ii,jj)=0; % set pixels in x with y~=1 to 0

idx=[ii,jj]; % indexes of pixels with y~=1

s=x(abs(y)-1 > tolerance); % values of pixels

end

Thanks.

## RE: One function returns the correct results, the opposite not. Why?

Cheers

Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

## RE: One function returns the correct results, the opposite not. Why?

## CODE --> Matlab

Not sure why you'd want to do this, but the two functions certainly perform opposite functions and neither returns an empty matrix (unless of course, no values satisfy the condition).