What Does A([i j], = J*A([i j], ; Mean in MatLab?

In summary, the code "A([i j],:) = J*A([i j],:)" in MatLab means performing matrix multiplication on matrices A and J, only using rows i and j of A and all columns. This is equivalent to multiplying only specific rows of A by J.
  • #1
RyMi
7
0
What Does A([i j],:) = J*A([i j],:); Mean in MatLab?

Title pretty much describes it all. I have no familiarity with MatLab and I'm translating an algorithm into Java. A and J are matrices and i and j are integers. I already have a Matrix class in Java that can handle most matrix operations, I just need to know what this means.
Thanks in advance
 
Physics news on Phys.org
  • #2


The ":" means all columns (or all rows if it were the 1st argument).

I think the [i j] in the first argument means row i and row j only.

So therefore A([i j],:) refers to all of (that is, all columns of) rows "i" and "j" only.

The "*" is just matrix multiplication but I guess you already know that part. :)
 

Related to What Does A([i j], = J*A([i j], ; Mean in MatLab?

1. What is the purpose of the A([i j], = J*A([i j], ; command in MatLab?

The A([i j], = J*A([i j], ; command in MatLab is used to multiply the elements of matrix A with the corresponding elements of matrix J, and assign the resulting values to the corresponding elements of matrix A. This is known as element-wise multiplication.

2. What is the difference between A([i j], = J*A([i j], ; and A([i j], = A([i j], * J; in MatLab?

The difference between these two commands lies in the order of multiplication. In A([i j], = J*A([i j], ;, the elements of J are multiplied with the corresponding elements of A, while in A([i j], = A([i j], * J;, the elements of A are multiplied with the corresponding elements of J. The resulting matrices will be different unless A and J are symmetric.

3. Can the A([i j], = J*A([i j], ; command be used for non-square matrices in MatLab?

Yes, the A([i j], = J*A([i j], ; command can be used for non-square matrices in MatLab as long as the dimensions of A and J are compatible for element-wise multiplication. This means that the number of rows and columns in A and J must be the same.

4. What happens if the dimensions of A and J are not compatible for element-wise multiplication in MatLab?

If the dimensions of A and J are not compatible for element-wise multiplication, MatLab will throw an error and the multiplication will not take place. It is important to ensure that the dimensions of A and J are compatible before using the A([i j], = J*A([i j], ; command.

5. How does A([i j], = J*A([i j], ; differ from regular matrix multiplication in MatLab?

A([i j], = J*A([i j], ; and regular matrix multiplication in MatLab are different in the way they compute the resulting matrix. In A([i j], = J*A([i j], ;, the elements of the resulting matrix are computed by multiplying the corresponding elements of A and J, while in regular matrix multiplication, the elements of the resulting matrix are computed by taking the dot product of the rows and columns of A and J. This means that the resulting matrices will be different unless A and J are symmetric.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
27
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
Back
Top