How to add labels to the LEFT of a table
조회 수: 7 (최근 30일)
이전 댓글 표시
Let's say we have a random table
T = readtable('indoors.csv');
head(T,3)
ans=3×3 table
Time Humidity AirQuality
___________________ ________ __________
2015-11-15 00:00:24 36 80
2015-11-15 01:13:35 36 80
The way we have VariableNames as'time' 'humidity' etc written, I want similar labels on the y-axis
Except instead of regular labels, I was labels like 'x[n]' and 'h[x]', but without it actually solving or giving me a concatenation error.
How can I do this?
or even just get me on the right track without doing x[n] stuff, please
This is my goal:
Time Humidity AirQuality
___________________ ________ __________
x[n] 2015-11-15 00:00:24 36 80
h[n] 2015-11-15 01:13:35 36 80
댓글 수: 0
채택된 답변
Star Strider
2021년 4월 25일
I’m not certain what you want.
Experiment with this —
Time = (datetime('2015-11-15 00:00:24')+hours(0:1.1:5.5)).';
Humidity = randi([1 100],size(Time));
AirQuality = randi([1 100],size(Time));
AirTable = table(Time,Humidity,AirQuality);
AirTable.Properties.RowNames = compose('x[%d]',1:numel(Time))
Alterrnatively, try this option —
AirTable.Properties.RowNames = compose('%s[n]','a'+randi([0 25],size(Time)));
.
댓글 수: 3
Star Strider
2021년 4월 26일
For only two rows, yes.
In that instance —
AirTable.Properties.RowNames = {'x[n]','h[n]'};
will work.
However, doing this —
xhvct = repmat({'x[n]','h[n]'},1,ceil(numel(Time)/2));
AirTable.Properties.RowNames = xhvct(1:numel(Time));
throws the error:
Duplicate table row name: 'x[n]'.
So, each row must have a unique row name, however you choose to define them.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!