Home > Enterprise >  Need to generate exponentional matrix
Need to generate exponentional matrix

Time:10-10

I need generate matrix in form like this

Exponential Matrix

without using any loops in Matlab. Where N has to be some var. I need some hints or way how to solve this.

CodePudding user response:

I see two simple ways to do this. Here are some hints:

  1. It can be done using element-wise multiplication of a row and column vector with singleton expansion.
  2. Alternatively, it can be done with matrix-multiplication of a column times a row vector (in that order).

I recommend that you read the pages linked above and give it a try yourself. Here are my solutions:

  1. Using singleton expansion:

N = 5; C = (0:N-1).*(0:N-1).'

  1. Using matrix multiplication:

N = 5; C = (0:N-1).'*(0:N-1)

  • Related