Vakath
Vakath

Reputation: 11

Matlab Syntax Help .'*

I am currently using the Eigen library to convert some Matlab code to c++. I have been given the matlab code and it's as follows:

I have 2 Matrices N_R, G_R.

N_R is a 8 row 10 col matrix while

G_R is a diagonal matrix of an 8 value vector

There is a system matrix that has the term N_R .' * G_R * N_R in it.

I am having real trouble with this term and haven't been able to find what this combination of . ' * actually does.

I'm guessing it's some kind of transpose and multiply but I keep getting errors about the dimensions being mismatched.

Upvotes: 1

Views: 65

Answers (2)

Dev-iL
Dev-iL

Reputation: 24179

As you said, .' is the transpose operator (notice: it does not contain spaces) in MATLAB, while * is matrix multiplication.

Now, let's review the rest (I took the liberty to put parentheses for clarity):

(N_R.') * (G_R) * (N_R)
  • N_R is 8x10, so N_RT is 10x8.
  • (N_R.') * (G_R) is 10x8 * 8x8, so 10x8.
  • (N_R.') * (G_R) * N_R is therefore 10x8 * 8x10, so 10x10.

Upvotes: 3

Johan Lundberg
Johan Lundberg

Reputation: 27088

The ' operator in matlab is performing matrix conjugate, while .' performs a simple transposition, as explained at Using transpose versus ctranspose in MATLAB. Note that . ' is not valid, but .' is.

N_R.' * G_R * N_R

would with Eigen (Tutorial Matrix Arithmetic) be

N_R.transpose() * G_R * N_R

(Thanks @Dev-iL for pointing out that I swapped the two meanings in the original version of the answer)

Upvotes: 4

Related Questions