If I have 512 matrices (entries of each matrix is looping modulo 2), how the multiplication syntax for those 512*512 matrices ?

1 visualización (últimos 30 días)
this is syntax for define the 512 matrices
clc,clear;
i=0;
modulo=2;
for A=1:modulo
for B=1:modulo
for C=1:modulo
for D=1:modulo
for E=1:modulo
for F=1:modulo
for G=1:modulo
for H=1:modulo
for I=1:modulo
M=[A-1 B-1 C-1 ; D-1 E-1 F-1 ; G-1 H-1 I-1];
i=i+1;
end
end
end
end
end
end
end
end
end
i
  5 comentarios
Torsten
Torsten el 13 de En. de 2022
Editada: Torsten el 13 de En. de 2022
On my PC, it works fine.
Maybe you changed "m" ?
Then you also have to change the size of the reshaped matrix accordingly:
A = reshape(justRows(i,:),[sqrt(m),sqrt(m)]);
If the error persists, include the code you are using together with the exact error message you receive.

Iniciar sesión para comentar.

Respuestas (1)

Torsten
Torsten el 12 de En. de 2022
Editada: Torsten el 12 de En. de 2022
m = 9;
justRows = dec2bin(0:2^m-1)-'0';
for i = 1:size(justRows,1)
A = reshape(justRows(i,:),[3,3]);
M{i} = A;
end
  11 comentarios
Regita Agustin Wahyu F
Regita Agustin Wahyu F el 7 de Jun. de 2022
ok thx sir. But can i make MM{(i-1)*n+j} = M{i}*M{j} times MM{(i-1)*n+j} = M{i}*M{j} ? with each MM{(i-1)*n+j} = M{i}*M{j} = 256 matrices if m = 4 as your code above. So later i'll get 65.536 matrices. I'm still confuse how to change the function
Torsten
Torsten el 7 de Jun. de 2022
Editada: Torsten el 7 de Jun. de 2022
I don't understand what you are asking.
Given m, you get 2^m matrices M and 2^(2*m) matrices MM.
So if m = 4, you get 16 matrices M and 256 matrices MM
If m = 9, you get 512 matrices M and 262144 matrices MM.
If m = 16, you get 65536 matrices M and 4294967296 matrices MM. But I doubt you have sufficient RAM to do that.

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by