Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- G = NaN(250,250);
- a = ceil(rand(1,50)*250*250);
- b = ceil(rand(1,50)*250*250);
- G (a) = 1; G (b) = 0;
- % find the non-NaN entries in G
- idx = ~isnan(G);
- % find their corresponding row/column indices
- [i,j] = find(idx);
- % resize your matrix as desired, i.e. scale the row/column indices
- i = ceil(i*100/250);
- j = ceil(j*100/250);
- % write the old non-NaN entries to Gnew using accumarray
- % you have to set the correct size of Gnew explicitly
- % maximum value is chosen if many entries share the same scaled i/j indices
- % NaNs are used as the fill
- Gnew = accumarray([i, j], G(idx), [100 100], @max, NaN);
Add Comment
Please, Sign In to add comment