且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

结合数字矩阵和字符串数组

更新时间:2023-02-06 17:35:08

最简单的解决方案是使用 num2cell 并将结果与​​字符串连接:

The simplest solution is to use num2cell and concatenate the result with the strings:

y = [{'A1', 'B1'}; num2cell(f)];

示例

>> f = reshape(1:10, 2, [])';
>> y = [{'A1', 'B1'}; num2cell(f)]

y =
    'A1'    'B1'
    [ 1]    [ 2]
    [ 3]    [ 4]
    [ 5]    [ 6]
    [ 7]    [ 8]
    [ 9]    [10]