Map matrix element to string

前端 未结 4 1091
深忆病人
深忆病人 2021-01-19 13:02

I would like to map numeric output from a matrix to a string.

Given

compute=[ 7, 4, 3; 3, 4, 7]

how can one obtain a string mappin

4条回答
  •  失恋的感觉
    2021-01-19 13:42

    I assume you have the map in a form of a cell array

    >> map{3} = 'Jog';
    >> map{4} = 'Walk';
    >> map{7} = 'Run';
    

    Now use the map

    map( compute )
    

    will give you a cell array of strings

提交回复
热议问题