To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
How can I vectorize the following three nested loops? I tried using arrayfun but I did not succeed in doing it.
% Range of random number for x and y. L = 8; H = 6;
% The number of random numbers. n = 100;
% Randomly spaced data. x = rand( n, 1 )*L; y = rand( n, 1 )*H;
d = .01; [ X, Y ] = meshgrid( 0:d:L, 0:d:H );
TOL = .01; I = zeros(size(X));
for i=1:size(X,1) for j=1:size(X,2) for k=1:numel(x) dist = (X(i,j)-x(k))^2+(Y(i,j)-y(k))^2; if( dist<TOL) I(i,j) = 1; end end end end
No products are associated with this question.