Import Excel-Sheet and plot time - error!
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have the following Excel-Sheet (attachement). The first column contains the time in the format 'HH:MM:SS' and the second column contains the forxe (integer).
data = xlsread('2018-12-07--15-55-46 - alt_1.csv');
time = data(:, 1);
force = data(:,2)
time_new_format = datestr(time, 'HH:MM:SS')
plot(time_new_format, force)
1. After running this code the following error occurs. "Error using plot Invalid first data argument." I guess because the new time is a string, maybe I must use datenum, but I don't know how.
2. My second problem is, when I want to check the force in the command window by entering "force" then the values are roundet up to 0.0015. Can I pevent Matlab from rounding up these values?
Thank you very much!
0 commentaires
Réponses (1)
YT
le 4 Fév 2019
Modifié(e) : YT
le 4 Fév 2019
This will do the job
clear;
opts = detectImportOptions('2018-12-07--15-55-46 - alt_1.csv','Delimiter',';');
opts = setvartype(opts,[1],'duration'); %as duration
opts = setvartype(opts,[2],'double');
opts = setvaropts(opts,[2],'DecimalSeparator',','); %your file contains `,` as decimal seperator; matlab uses `.` for decimals
T = readtable('2018-12-07--15-55-46 - alt_1.csv',opts); % read in your file
T = [array2table(seconds(T{:,1})) T(:,2)]; %change the HH:mm:ss time format using `seconds`
plot(T{:,1},T{:,2});
If you want to display the values with all decimals in the command window use
format longG
T{1,2}
%>> 0.00145743
0 commentaires
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!