How to create variable name for .CSV file in matlab?

8 visualizaciones (últimos 30 días)
Haritha
Haritha el 27 de Nov. de 2018
Comentada: Jan el 29 de Jul. de 2020
Hi,
I have CSV file as below
Main.JPG
I want to create names for VarName upto end of the matrix. I have to write the code for changing the VarNames automatically. I need the output as below. Please let me know if anyone knows the ans.
output_image.JPG
Thank you in advance.
  3 comentarios
Jan
Jan el 27 de Nov. de 2018
Editada: Stephen23 el 28 de Nov. de 2018
Do you want to assign names for a table object inside Matlab or to modify the file?
Haritha
Haritha el 28 de Nov. de 2018
Editada: Haritha el 28 de Nov. de 2018
I want inside the code only. I am attaching one .csv file for experiment.Please check and let me know. Thank you in advance

Iniciar sesión para comentar.

Respuestas (1)

Arunkumar M
Arunkumar M el 28 de Nov. de 2018
Hope you have already imported data into workspace as table. Assuming table name is Reducedfeatures
% for defining name for all columns at once
Reducedfeatures.Properties.VariableNames = {'C1','C2',.......}
% for defining specific column names, example: first and second column
Reducedfeatures.Properties.VariableNames([1:2]) = {'C1','C2'}
  4 comentarios
Claudio Ignacio Fernandez
Claudio Ignacio Fernandez el 28 de Jul. de 2020
Hello
I'm following your example but I'm getting this message
Unable to perform assignment
because dot indexing is not
supported for variables of this
type.
Jan
Jan el 29 de Jul. de 2020
@Claudio: Please post your code. How is your variable called "Reducedfeatures" here defined in your case?

Iniciar sesión para comentar.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by