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

2 views (last 30 days)
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 Comments
Torsten
Torsten on 13 Jan 2022
Edited: Torsten on 13 Jan 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.

Sign in to comment.

Answers (1)

Torsten
Torsten on 12 Jan 2022
Edited: Torsten on 12 Jan 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 Comments
Regita Agustin Wahyu F
Regita Agustin Wahyu F on 7 Jun 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 on 7 Jun 2022
Edited: Torsten on 7 Jun 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.

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!