Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If there are 2 matrices a and b, what does a(b) do in matlab?

If I have a matrix, say

a = [1 2 3;
     4 5 6]

and

b = [2 2 2;
     3 3 3]

when I do a(b) in matlab, I get the answer as

a(b) = [4 4 4;
        2 2 2]

what exactly is happening here ?

like image 484
user2827872 Avatar asked Sep 29 '13 07:09

user2827872


People also ask

What does AB means in MATLAB?

A\B returns a least-squares solution to the system of equations A*x= B.

What does a * b do in MATLAB?

Description. C = A . * B multiplies arrays A and B by multiplying corresponding elements. The sizes of A and B must be the same or be compatible.

What is the difference between a B and a B in MATLAB?

Mathworks releases different Matlab versions. The four digit number represents the year in which that particular version is released and the alphabets(a/b) indicates the higher versions(b is newer version than a).

How do you compare two matrices equal in MATLAB?

A == B will return a matrix the same size as A (and B) telling you which elements of A are equal to the corresponding element of B. isequal(A, B) will return a single true/false telling you if all the elements of A are the same as the ones in B.


1 Answers

You're indexing a with each item in b. a(2) = 4 and a(3) = 2

so

c = [a(2) a(2) a(2); a(3) a(3) a(3)] 

is what you're seeing.

like image 164
user2759991 Avatar answered Oct 05 '22 22:10

user2759991