Effortlessly Compute A*B with MATLAB: Simple 100x30 Output Matrix Calculation

In summary, The conversation discusses the desire to find the product of two matrices, A and B, and create a 100x30 output matrix where each element represents the sum of the products of corresponding elements from the k-th plane of A and m-th plane of B. The individual seeking help is looking for a short line of code to perform this calculation. A possible solution is suggested using a for loop, but the user is not familiar with Matlab.
  • #1
mikeph
1,235
18
hi simple computation

A = 60x60x100
B = 60x60x30

I want to find A*B, by this I mean, I want a 100x30 output matrix where element (k,m) represents the sum of A(i,j,k)*B(i,j,m) over all i,j

My brain is simply not working and I'm confusing myself, does anyone have a short line of code to calculate this sum?
 
Physics news on Phys.org
  • #2
MikeyW said:
hi simple computation

A = 60x60x100
B = 60x60x30

I want to find A*B, by this I mean, I want a 100x30 output matrix where element (k,m) represents the sum of A(i,j,k)*B(i,j,m) over all i,j

My brain is simply not working and I'm confusing myself, does anyone have a short line of code to calculate this sum?

If I understand you correctly, then you want to perform an element-by-element multiplication of the k-th plane of A and the m-th plane of B and sum the products to form 100 x 30 matrix?

I'm not a Matlab user, but would something like the following be along the right kind of lines?

for k = 1:100
for m = 1:30
p(k,m)=sum(sum(A(:,:,k) .* B(:,:,m)))

NR
 

Related to Effortlessly Compute A*B with MATLAB: Simple 100x30 Output Matrix Calculation

What is MATLAB?

MATLAB is a programming language and software environment commonly used in scientific and engineering applications. It allows for data manipulation, visualization, and the creation of algorithms and models.

What is the purpose of "Effortlessly Compute A*B with MATLAB: Simple 100x30 Output Matrix Calculation"?

The purpose of this program is to provide a simple and efficient way to calculate the product of two matrices (A and B) with the use of MATLAB. It is specifically designed for a 100x30 output matrix calculation, making it useful for various research and analysis tasks.

How can I use this program?

To use this program, you will need to have MATLAB installed on your computer. You can then open the program and input your desired values for matrices A and B. The program will then perform the calculation and output a 100x30 matrix.

Is this program user-friendly?

Yes, this program is designed to be user-friendly and easy to use. It requires minimal input from the user and provides a straightforward output. It also has clear instructions and guidelines for use.

Can this program be modified for different matrix sizes?

While this program is specifically designed for a 100x30 output matrix calculation, it can be modified for different matrix sizes. However, this may require some changes to the code and input parameters. It is recommended to consult a MATLAB expert for assistance in modifying the program for different matrix sizes.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top