MATLAB Answers

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

33 ビュー (過去 30 日間)
Haritha
Haritha 2018 年 11 月 27 日
Commented: Jan 2018 年 11 月 28 日
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 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 27 日
upload sample csv file to experiment
Jan
Jan 2018 年 11 月 27 日
Do you want to assign names for a table object inside Matlab or to modify the file?
Haritha
Haritha 2018 年 11 月 28 日
I want inside the code only. I am attaching one .csv file for experiment.Please check and let me know. Thank you in advance

サインイン to comment.

件の回答 (1)

Arunkumar M
Arunkumar M 2018 年 11 月 28 日
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'}

  2 件のコメント

madhan ravi
madhan ravi 2018 年 11 月 28 日
+1
Jan
Jan 2018 年 11 月 28 日
To create the list of names dynamically:
Reducedfeatures.Properties.VariableNames = sprintfc('Hist_fea%d', 1:23)

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by