How to call a .txt file containing dates in format "01-JAN-2019" and time against three other independent variables to MATLAB?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Akshay Saini
il 15 Apr 2021
Risposto: Walter Roberson
il 16 Apr 2021
Ive attached the file i'd like to call and then use to plot further into multiple plots, however when I use "fileread('data.txt')", I get all the data in a 1xn matrix that I cannot use to plot.
3 Commenti
Rik
il 15 Apr 2021
If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks).
Risposta accettata
Walter Roberson
il 16 Apr 2021
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/584765/data.txt';
t = readtable(filename, 'Format', '%s%s%s%s%C%C%C', 'readvariablenames', false);
t.Time = datetime(strcat(t{:,1},'-',t{:,2},'-',t{:,3},{' '},t{:,4}));
t.Properties.VariableNames(5:7) = {'Status1', 'Status2', 'Status3'};
plot(t.Time, t.Status1)
Not the greatest of plots, but the data cannot be treated as numeric as it contains entries such as InVld and NoData and <Samp and down and pwrfail and ca1 and it is difficult to know how to plot those.
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!