필터 지우기
필터 지우기

Reading column labels in a Matrix

조회 수: 5 (최근 30일)
Shiladitya Chatterjee
Shiladitya Chatterjee 2016년 8월 26일
편집: the cyclist 2016년 8월 28일
I have a 65536x93 dataset with column labels which are numbers. I want to store the column labels in a 1x93 matrix with the labels as numbers which will be used as the x-axis in a plot.
Please help
  댓글 수: 3
Image Analyst
Image Analyst 2016년 8월 27일
Most people have switched over to tables now, instead of the deprecated dataset. Can you use a table instead?
Shiladitya Chatterjee
Shiladitya Chatterjee 2016년 8월 27일
@the cyclist Yes, it is a Matlab dataset array. All I want is to extract the column labels!!

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

답변 (2개)

Image Analyst
Image Analyst 2016년 8월 27일
If you have a table, you can use the "fieldnames" method:
%%Create Table from Workspace Variables
% Define workspace variables with the same number of rows.
LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'};
Age = [38;43;38;40;49];
Height = [71;69;64;67;64];
Weight = [176;163;131;133;119];
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];
Create a table, T, as a container for the workspace variables.
T = table(Age,Height,Weight,BloodPressure,...
'RowNames',LastName)
table names the variables with the workspace variable names.
f = fieldnames(T)
  댓글 수: 1
Shiladitya Chatterjee
Shiladitya Chatterjee 2016년 8월 27일
Unfortunately, this a Matlab dataset array which is part of a Demo data from a toolbox. All I want is to extract the column labels. I can see them when I open the array but can't really access them!!

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


the cyclist
the cyclist 2016년 8월 28일
편집: the cyclist 2016년 8월 28일
Based on the example on this page, I would try
putYourDatasetNameHere.Properties.VarNames
For example
load hospital % This is an example dataset pre-loaded in MATLAB
hospital.Properties.VarNames
will display the variable names, and you can also use that to label ticks.
figure
set(gca,'XTickLabel',hospital.Properties.VarNames)

카테고리

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