Why does my .csv file create spaces between each of my data points? It makes it to where I cannot graph precipitation against the date.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Jack Jones
am 28 Nov. 2022
Kommentiert: Jack Jones
am 28 Nov. 2022
% I have also attached the data I am trying to extract the data from
clearvars
clear all
clc
% Open data
fid=fopen('2022BRPREC.csv','r');
data=textscan(fid,'%s%s%s%s%s%s%s','headerlines',1,'delimiter',',');
fclose=(fid);
% Name 2022 Variables
date22=data{4};
prec22=data{5};;
figure
cc=plot(date22,prec22);
2 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
millercommamatt
am 28 Nov. 2022
You're defining the columns as strings so the output is going to include whitespace.
You want something like:
...
data = textscan(fid,'%s%s%{MM/dd/yyyy}D%f%f%f%f%f','headerlines',1,'delimiter',',');
...
2 Kommentare
Siehe auch
Kategorien
Mehr zu Data Import and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!