From: ibrahim on 19 Apr 2010 14:32 Hey every one................... i have this script xn = zeros(size(x)); M = size(x,1); r = zeros(M,1); row = 0; for i = length(n):-1:1 indxs = reshape(1:M*n(i),n(i),M)'; indxs = fliplr(indxs); % Flip martrix left-to-right subMatrix = x(end:-1:1,end-n(i)+1:end); x(:,end-n(i)+1:end) = []; for j=1:M:numel(subMatrix) pp = 1; for k=j:j+M-1 r(pp)=find(indxs==k,1); pp = pp + 1; end temp = zeros(size(subMatrix)); temp(r) = 1; temp = temp(end:-1:1,:); row = row + 1; xn(row,:) = subMatrix(temp == 1); end end this code is used to rearrange a square matrix f using a specific vector n using the baker chaotic map class B. this code is working fine, but it takes alot of time in the (FIND) function. i want to rewrite this script to take much lower time to excute. thanks.
From: Jan Simon on 21 Apr 2010 17:04 Dear Ibrahim! > indxs = reshape(1:M*n(i),n(i),M)'; > indxs = fliplr(indxs); % Flip martrix left-to-right > ... > r(pp)=find(indxs==k,1); As far as I can see, the FIND is not necessary at all: v = []; v(indxs(:)) = 1:M*n(i); for k = ... r(pp) = v(k); And in consequence even the FOR loop can be omitted. Jan
|
Pages: 1 Prev: Plot (real time) Next: hdrread function issue (Image processing toolbox) |