I want to know how to multiply array elements one by one.
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I have some problems with making matlab code.
If I have 2x2 matrix. I want to calculate (1,1)x(1,1), (1,1)x(1,2) (1,1)x(2,1), (1,1)x(2,2)
(1,2)x(1,2), (1,2)x(2,1), (1,2)x(2,2) -> (1,2)x(1,1) is already exists in the first row.
(2,1)x(2,1), (2,1)x(2,2) -> (2,1)x(1,1), (2,1)x(1,2) are already existed in the previous rows.
(2,2) values.
(1,1) is the element of matrix value. for example) if matrix [1,2,3;4,5,6;7,8,9], then (1,1) means 1.
So, what I want to say is (1,1)x(1,2) = 1x2=2.
I want to expand this to m x m matrix.
how I make the code or which function should I use?
Until now I have used just ' for '.
I made the code with 4 parameter (ex) i,j,k,l)
However, this operation has duplicate values, and as the matrix becomes large, the operation speed becomes significantly longer.
plz help me....
7 Kommentare
Antworten (1)
Arif Hoq
am 15 Mär. 2022
A=[1 2; 3 4];
B1=A(1,1)*A(:);
B2=A(1,2)*A(:);
B3=A(2,1)*A(:);
B4=A(2,2)*A(:);
matrix=[B1 B2 B3 B4];
out=reshape(matrix,1,[]);
out2=unique(out)
And I will save this result to the n x 2 matrix. In the above case, n=10.
no, its 9 element row vector. so you can not reshaped into n X 2 arrray.
5 Kommentare
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!