2

如何将垂直矩阵转换为水平矩阵?

我的代码:

headersName = get(handles.tagTable, 'ColumnName');

headersName = 

    'Col1'
    'Col2'
    'Col3'
    'Col4'

但我需要这样的水平矩阵:

headersName =

     'Col1'  'Col2'  'Col3'  'Col4'
4

2 回答 2

2

考虑到headersNameMATLAB 打印的方式,它看起来像是一个字符串单元数组,所以一个简单的转置应该可以工作

headersName = get(handles.tagTable, 'ColumnName').';

否则,如果它是一个字符串数组,您可以cellstr将其转换为元胞数组,然后应用转置:

headersName = cellstr(get(handles.tagTable, 'ColumnName')).';
于 2013-11-08T09:17:12.397 回答
0

在这种情况下最好使用单元阵列:

headersName={'Col1';'Col2';'Col3';'Col4'}

标题名称 =

'Col1'
'Col2'
'Col3'
'Col4'

标题名称'

答案=

'Col1'    'Col2'    'Col3'    'Col4'        
于 2013-11-08T09:14:19.230 回答