Reading column labels in a Matrix
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
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 comentarios
  Image Analyst
      
      
 el 27 de Ag. de 2016
				Most people have switched over to tables now, instead of the deprecated dataset. Can you use a table instead?
Respuestas (2)
  Image Analyst
      
      
 el 27 de Ag. de 2016
        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)
  the cyclist
      
      
 el 28 de Ag. de 2016
        
      Editada: the cyclist
      
      
 el 28 de Ag. de 2016
  
      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)
0 comentarios
Ver también
Categorías
				Más información sobre Tables en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


