csv file import with exponential notation
Mostrar comentarios más antiguos
Hello,
I importet data from a sensor reading and wanted to plot them (force over time)
as the force data contained commata I had to convert them, but I still have a wrong graph as the exponential notation is not 'detected'.
This is my script:
%%read txt file with force measurement, save datevec
Data = readtable('CSV-file.csv','TextType','string'); %add name of csv file (readtable)
waveform = table2array(Data(:,1)); %table to cell time vector
Y = table2array(Data(:,2)); %save force in waveform
Y([1,2,3,4,5],:) = []; %delete rows 1-5 force vector
waveform([1,2,3,4,5],:) = []; %delete rows 1-5 time vector
Data2 = strrep(Y, ',', '.');
Timevector = datetime (waveform ,'InputFormat','dd.MM.yyyy HH:mm:ss,SSSSS');
Data21 = categorical(Data2(:,1));
plot (Timevector, Data21,'b*');
yyy HH:mm:ss,SSSSS');
Data21 = categorical(Data2(:,1));
plot (Timevector, Data21,'b*');
my Data (.csv):

and this is my current plot vs. the actual plot:

is there a way to format the string, so that the exponential notation is right?
1 comentario
Ameer Hamza
el 29 de Dic. de 2020
Editada: Ameer Hamza
el 29 de Dic. de 2020
Can you attach some sample datapoints from as a csv file?
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 29 de Dic. de 2020
0 votos
Use the decimalseparator option for readtable
https://www.mathworks.com/help/matlab/ref/detectimportoptions.html#d122e302928
I think it became available as of R2020a but that would have to be checked
1 comentario
Walter Roberson
el 29 de Dic. de 2020
You might need Prefix and Suffix to get rid of quote marks
Categorías
Más información sobre LaTeX en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!