analyse table by row name
1 view (last 30 days)
Dion Theunissen on 25 May 2021
I have two questions.
I read a csv file in matlab as below:
Now i want to sort the table by the first column. I only want to read the number that i have to fill in in the script. So that i can say, only read vin number ..... and use that data. Thats the first part.
My second question is how to use the date column on the right way? I want to use it in a plot but the last numbers are a bit weird. How can I read this and use this in a plot?
anyone who can help me?
Aghamarsh Varanasi on 28 May 2021
You can import the data as a table from csv form the import gui. To sort the table based on the first row, you can use 'sortrows' function. You can sort the table based on any given column. For example,
% to sort the table data based on first column. Lets assume data is saved
% in a table variable named 'table_data'
table_data = sortrows(table_data,1);
table_data_firstcolumn = table_data.vin; % access data in first column
To handle data in the format of date and time, 'datetime' function provides a way to import and convert the data in 'datetime' format. 'datetime' data can also be used in a plot. In your case, you can use the following code snippet to extact the date and time date.
time_data = table_data.createdDateTime;
time_array = datetime(time_data, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z')
Hope this helps