Name the first column in array2table

조회 수: 7 (최근 30일)
kimmy8
kimmy8 2019년 11월 21일
답변: Star Strider 2019년 11월 21일
How do I name the first column of the table? I am able to name the other columns, but not the column that was not included in the 6x6 table. I want to name the first column Property. (in matlab R2019)
Property = {'Salinity','Oxygen','Nitrate','Silicate','Temperature','Phosphate'}
T = array2table(coeff,'VariableNames', {'Mode_1','Mode_2','Mode_3','Mode_4','Mode_5','Mode_6'},...
'RowNames', Property);

채택된 답변

Star Strider
Star Strider 2019년 11월 21일
The code you posted produces an acceptable table object.
I am not certain what you want. I am guessing here:
coeff = rand(6);
Property = table({'Salinity','Oxygen','Nitrate','Silicate','Temperature','Phosphate'}','VariableNames',{' '});
T = array2table(coeff,'VariableNames', {'Mode_1','Mode_2','Mode_3','Mode_4','Mode_5','Mode_6'})
T = addvars(T, Property, 'Before','Mode_1')
producing:
T =
6×7 table
Property Mode_1 Mode_2 Mode_3 Mode_4 Mode_5 Mode_6
_______________ _______ ________ _______ _______ _______ _______
{'Salinity' } 0.181 0.72568 0.33711 0.37855 0.32149 0.971
{'Oxygen' } 0.80879 0.15401 0.44594 0.42276 0.89985 0.55552
{'Nitrate' } 0.81906 0.50907 0.75765 0.97269 0.54211 0.76982
{'Silicate' } 0.48724 0.66804 0.13053 0.17702 0.46289 0.68012
{'Temperature'} 0.75505 0.15258 0.90151 0.88228 0.80797 0.2052
{'Phosphate' } 0.40437 0.062696 0.22034 0.55126 0.36082 0.83462
Please be specific if you want to do something else.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by