How do I convert the vector to matrix 16 * 16

4 views (last 30 days)
Can anyone help me
In this function i have vector , i want convert the vector to matrix 16 * 16
function inv_s_box = s_box_inversion (s_box)
for i = 1 : 256
inv_s_box(s_box(i) + 1) = i ;%- 1;
end

Accepted Answer

Cris LaPierre
Cris LaPierre on 4 Mar 2021
inv_s_vox = reshape(1:256,[16,16])
inv_s_vox = 16×16
1 17 33 49 65 81 97 113 129 145 161 177 193 209 225 241 2 18 34 50 66 82 98 114 130 146 162 178 194 210 226 242 3 19 35 51 67 83 99 115 131 147 163 179 195 211 227 243 4 20 36 52 68 84 100 116 132 148 164 180 196 212 228 244 5 21 37 53 69 85 101 117 133 149 165 181 197 213 229 245 6 22 38 54 70 86 102 118 134 150 166 182 198 214 230 246 7 23 39 55 71 87 103 119 135 151 167 183 199 215 231 247 8 24 40 56 72 88 104 120 136 152 168 184 200 216 232 248 9 25 41 57 73 89 105 121 137 153 169 185 201 217 233 249 10 26 42 58 74 90 106 122 138 154 170 186 202 218 234 250

More Answers (2)

William Rose
William Rose on 4 Mar 2021
I assume that s_box is the vector you want to reshape.
s_box = reshape(s_box,[16,16])

sarah
sarah on 5 Mar 2021
think you so much

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!