Hello,
So imagine if i have this calculation to make
A = [1,2,3,4,5,6,7,8,9,10];
B = zeros(1,10);
for j = 1:10
B = 1+A;
end
The end result is a matrix B like B = 2 3 4 5 6 7 8 9 10 11.
In the workspace I have a table B to open, it open "like" the tables from excel, I was wondering if I can change the header to let's say X1,X2,X3,...Xn, being n the number of columns of A.
Thanks for your time, Tiago

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2018년 1월 30일
편집: Andrei Bobrov 2018년 1월 30일

1 개 추천

B = 2:11;
out = array2table(B,'v',cellstr(string('X') + (1:numel(A))'))

댓글 수: 5

Tiago Dias
Tiago Dias 2018년 1월 30일
thanks will try, what does the 'v' means?
Tiago Dias
Tiago Dias 2018년 1월 30일
Thanks it works perfect.
Andrei Bobrov
Andrei Bobrov 2018년 1월 30일
'v' this is 'VariableNames'.
A = [1,2,3,4,5,6,7,8,9,10];
B = zeros(1,10);
for j = 1:10
B = 1+A;
C = 10*A;
end
out = array2table(B,'v',cellstr(string('X') + (1:numel(A))'))
i would like to place the B in the 1st row, and the C in the 2nd row, and i would like to title the 1st row as B and the 2nd row as C, while the columns are still X1 to X10
got it,
merge table = [B;C]
'RowNames',{'B','C'}

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

질문:

2018년 1월 30일

댓글:

2018년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by