Hi guys, maybe anyone have an idea for my problem here. I just struggleing a little bit with finding another way of implementation to get rid of this for-loop. Is there maybe a way to get rid of the slow for-loop? Thank you for your help!
%Create example variablesval = zeros(2000,2000);a = 1:100:2000;b = 100:100:2099;count = 1;for kk = 1:numel(a)for jj = 1:numel(a)for ii = 1:numel(a)val(a(jj):b(ii),a(kk):b(kk)) = count;endcount = count + 1;endendlist = unique(val);%Create space between grids (needed speed-up)for ii = 1:length(list)[y,x] = find( val == list(ii) );minx = min(x);maxx = max(x);miny = min(y);maxy = max(y);minx1 = ceil(minx + 0.05 * (maxx - minx ));maxx2 = ceil(maxx - 0.02 * (maxx - minx ));val(y,minx:minx1) = 0;val(y,maxx2:maxx) = 0;miny1 = ceil(miny + 0.05 * (maxy - miny ));maxy2 = ceil(maxy - 0.02 * (maxy - miny ));val(miny:miny1,x) = 0;val(maxy2:maxy,x) = 0;end
What I want to do is, splitting 'val' into seperated grids with space between grids. Maybe there is a better way to do this step 😀