Map matrix element to string

前端 未结 4 1234
深忆病人
深忆病人 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:29

    You can use cell array

    strs = {'one','two','Jog','Walk','five','six','Run'};

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

    out = strs(compute);

    out =

    'Run'    'Walk'    'Jog'
    'Jog'    'Walk'    'Run'
    

提交回复
热议问题