How do I extract the Datetime array from the CSV ?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to extract the Average Ice concentration and date time from the CSV file. I managed to extract the Average ice concentration, but for the date time it is extracting as individual cell arrays with datetime in eah cell as follows
I would want it to extract the datetime like this (from another project but cell2mat doesnot work here)
The cell2mat function doesnot work. I would want some recommendations on how to proceed.
The code is as follows
%% Importing data file
% Note: The text file has headers and two columns:
% Column 1 - example of entry: {[2010-12-16 0:00]}
% Column 2 - Ice concentration Min
% Column 3 - Ice concentration Average
% Column 4 - Ice concentration Max
%% Because these are two different data types, they need to be imported as a CELL ARRAY
B=readcell('Ice concentration data.csv'); % Note: The csv format is automatically recognized.
B(1:1,:) = []; % Removing top rows (headers)
%% From this array, we extract the Average Ice Concentration levels
% Average Ice Concentration levels - production of a one-column numeric matrix
average_ice_concentration_level = cell2mat(B(:,3));% Converting average ice concentration from numeric cell
% to numeric vector (matrix)
%% From the same array, we extract date, month, day
% Step 1: Production of a character vector matrix
date_ice_concentration = (B(:,1));
0 Commenti
Risposta accettata
Star Strider
il 7 Nov 2022
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1184228/Ice%20concentration%20data.csv')
T1.DateTime
VN = T1.Properties.VariableNames;
lgdstr = cellfun(@(x)strrep(x,'_','\_'), VN(2:end), 'Unif',0)
figure
plot(T1.DateTime, T1{:,2:end})
grid
legend(lgdstr, 'Location','best')
.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Tables in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!