I have a 2D matrix
containing only integers. I also have a cell array tickerList
that contains names of equity tickers. The number of columns in matrix
equals the number of elements in tickerList
.
I am trying to create cellArrayNew
by replacing the integers within matrix
by its corresponding names in tickerList
. So, for example, if matrix(1,1)=3
and tickerList(3)='S&P 500'
, I would like to have cellArrayNew(1,1)='S&P 500'
.
Just use the matrix as an index into
tickerList
:If the matrix contains indices that are somehow not in
tickerList
, useismember
:Result of my example: