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

Antworten (2)

David Sanchez
David Sanchez am 7 Aug. 2014

0 Stimmen

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 am 7 Aug. 2014

0 Stimmen

x=[1 5 8 0 6 1]
header=genvarname(repmat({'x'},1,size(x,2)),'x')
out=[header;num2cell(x)]

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 7 Aug. 2014

Beantwortet:

am 7 Aug. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by