From: ibrahim on
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
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