Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Concateniting the results of two “finds”

2 visualizaciones (últimos 30 días)
med-sweng
med-sweng el 23 de Feb. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I have the following function that based on some criteria sets some pixels to the value `1`, and based on another criteria sets the other pixels to the value `0`.
Note here that for each elements in `x` there is a matrix `y` that represents the degree of membership of each element in `x` to some region, and is in the range `[0,1]`.
tolerance = 0.01;
[ii,jj]=find(abs(y-1) <= tolerance);
x(ii,jj)=1; % set pixels in x with y=1 to 1
[ii2,jj2] = find (abs(y-1) > tolerance);
x(ii,jj)=0; % set pixels in x with y~=1 to 0
%idx=[ii,jj];
c=x(abs(y-1) <= tolerance); % values of pixels
My question is, as an *output*, I want a vector of values that look like this for instace: `[1 0 0 1 0 1 0 0]`
As you can see I set some pixels to `1` and other to `0`. How can I combine those two results together?
Thanks.

Respuestas (2)

Azzi Abdelmalek
Azzi Abdelmalek el 23 de Feb. de 2013
Your code can be done like this
tolerence=0.01;
y=0.05*(rand(5)-0.5) % your data
x=zeros(5)
x(abs(y)<=tolerence)=1
But your your output is not a vector

Walter Roberson
Walter Roberson el 23 de Feb. de 2013
As was already explained in one of your previous questions, you are using the output of find() incorrectly.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by