フィルターのクリア

how can i put a label for columns in an array?

2 ビュー (過去 30 日間)
arkedia
arkedia 2014 年 8 月 7 日
回答済み: Azzi Abdelmalek 2014 年 8 月 7 日
i have a vector as follows
x=[1 5 8 0 6 1]
i want result to be
x1 x2 x3 x4 x5 x6
1 5 8 0 6 1
how can i do it??

回答 (2 件)

David Sanchez
David Sanchez 2014 年 8 月 7 日
x=[1 5 8 0 6 1];
C=cell(2,length(x));
for k=1:length(x)
C{1,k} = sprintf('x%g',k);
C{2,k} = x(k);
end
disp(C)
'x1' 'x2' 'x3' 'x4' 'x5' 'x6'
[ 1] [ 5] [ 8] [ 0] [ 6] [ 1]

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 7 日
x=[1 5 8 0 6 1]
header=genvarname(repmat({'x'},1,size(x,2)),'x')
out=[header;num2cell(x)]

カテゴリ

Help Center および File ExchangeArgument Definitions についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by