I have a program written on Matlab as follows:
if nargin <2
error('PERMS1:minrhs','Two Input Arguments are required.')
end
if fix(n) ~= n || fix(b) ~= b ||n < 0 || b < 0 || ~isa(n,'double') || ~isa(b,'double') || ~isreal(n) || ~isreal(b)
error('PERMS1:nnegint','Input Parameters n and b Must be Non-negative Integers');
end
a=factorial(n:-1:1);
if b>a
error('PERMS1:brange','Input Parameter b Should be between 1 and n!')
end
p=zeros(1,n);
idx=ones(1,n);
id=find(a<b,1);
for i=id-1:n-1
d=mod(b,a(i+1));
idx(i)=floor(b/a(i+1))+(d~=0);
b=d;
if d==0
for j=i+1:n-1
idx(j)=n-j+1;
end
break;
end
end
m=1:n;
for i=1:n
p(i)=m(idx(i));
m=m(m~=p(i));
end
n = 8;
x0 = 13294;
c = 21;
x = zeros(1,256);
xi = x0;
i3=zeros(1,n);
for k = 1:256
i2 = floor(sin((pi/2)*((xi/(gt - 1))+((c+1)/(gt + 1))))*(gt - 1));
I2 = perms1(8,i2+1);
I1 = perms1(8,xi+1);
for i=1:n
i3(i)= I1(I2(i));
end
for i = 1:gt
if i3==perms1(8,i)
x(k)=i;
break;
end
end
xi = x(k);
disp(['k=',int2str(k),'x(k)=', int2str(x(k))]);
end
S = zeros(1,256);
for j = 1:256
S(j)= j ;
end
for i = 1 :256
j = floor(x(i)/gt*2^8);
if j==0
j=256;
end
t = 2^8 - i;
if t==0
t=256
end
a = S(j);
S(j)= S(t);
S(t) = a;
end
for i = 1:256
disp(S(i));
end
xlswrite('D:\test.xlsx',S);
I want to convert i, j = 1: 256 to 0: 255, what should I do?
Please help me!