I have the following function in matlab.
function s = value(x, y)
for i=1:length(y)
for j=1:length(y)
if y(i,j) ~= 0.5;
pixels = x(i,j);
end
end
end
pixels
end
When I run it, I just get the last pixel in the results. How can I get the vector of all results?
Thanks.
You need to keep an index:
However, you should vectorise your code to make it more efficient and easy to read, that function could be replaced by: