# How to create an array without duplicate values

2 views (last 30 days)
sarah on 9 Feb 2021
Commented: Rena Berman on 6 May 2021
Hi, can anyone help me? I want to create a 16 * 16 matrix using four important equations:
1. x(i)=r+(1-x(i-1))^2 ,r=0.2; x(1)=0.8.
2. X(i+1)=m1*x(i)*(1-x(i))+u1*Y(i)^2;
Y(i+1)=m2*Y(i)*(1-Y(i))+u2*((X(i)^2)+X(i)*Y(i)); u1=0.15;u2=0.13;Y(1)=0.2; X(1)=0.6;m1=2.76;m2=3.45;n=15;
3. X3d(i)=Q*(Y(i-1)-X(i-1));
yy(i)=r*X(i-1)-yy(i-1)-X(i-1)*z0(i-1);
z0(i)=X(i-1)*yy(i-1)+b*z0(i-1); r = 28; b = 8/3; yy(1) = 20; z0(1) = 30; Q=10;
4. z0(i)=X(i-1)*yy(i-1)+b*z0(i-1);
And I should have non-repeated values between 0 and 255
clear all;clc;
r=0.2;x(1,1)=0.8;
for i=2:64
x(i)=r+(1-x(i-1))^2;
end
A=reshape(x,8,[]);
u1=0.15;u2=0.13;Y(1)=0.2; X(1)=0.6;m1=2.76;m2=3.45;n=15;
for i=1:63
X(i+1)=m1*x(i)*(1-x(i))+u1*Y(i)^2;
Y(i+1)=m2*Y(i)*(1-Y(i))+u2*((X(i)^2)+X(i)*Y(i));
end
B=reshape(X,8,[]);
AB=([A,B])
r = 28; b = 8/3;
yy(1) = 20; z0(1) = 30; Q=10;
for i=2:64
X3d(i)=Q*(Y(i-1)-X(i-1));
yy(i)=r*X(i-1)-yy(i-1)-X(i-1)*z0(i-1);
z0(i)=X(i-1)*yy(i-1)+b*z0(i-1);
end
C=reshape(X3d,8,[]);
D=reshape(z0,8,[]);
CD=([C,D]);
all_matrix=([AB;CD]);
new_allmatrix =round(mod(all_matrix*10^5,256));
new_allmatrix =
128 151 252 249 49 224 191 178 0 39 95 255 36 123 157 237
192 60 40 63 172 217 235 242 128 56 46 121 250 175 96 198
192 145 73 180 21 213 187 176 144 37 217 220 154 126 179 44
114 69 136 100 187 223 237 243 121 132 231 242 118 100 44 156
43 11 190 126 255 204 183 175 211 135 164 64 38 55 52 159
2 16 212 130 200 228 239 244 8 183 44 39 63 22 28 161
86 225 80 83 238 197 180 173 66 77 256 125 22 166 146 196
220 174 15 154 209 232 241 245 83 162 166 108 48 116 194 115
96 7 22 171 155 111 225 237 192 37 210 36 0 0 0 0
216 65 140 217 91 156 150 41 128 157 194 160 0 0 0 0
197 71 113 3 232 161 106 253 165 75 250 64 0 0 0 0
188 35 135 128 198 169 228 78 5 252 165 128 0 0 0 0
224 8 93 230 254 17 248 14 172 69 30 0 0 0 0 0
193 184 99 152 2 234 140 132 159 130 41 0 0 0 0 0
124 23 91 201 29 213 202 215 169 38 138 0 0 0 0 0
70 71 49 112 72 153 195 59 179 87 80 0 0 0 0 0
##### 2 CommentsShowHide 1 older comment
Rena Berman on 6 May 2021

Walter Roberson on 9 Feb 2021
First fill each quarter according to a different ones of the formulas.
Now look for duplicates. For each of the copies other than the first, use one of the other formulas for that position, ensuring that the new values do not clash either.
In theory you might need to "back up" in your choices. Worry about how to handle that only if it happens.
sarah on 9 Feb 2021
Thank you very much for directing on the topic
If it is possible to clarify what this code needs to work well