String with csv in matlab
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi I have a string in matlab A = "2011-08-18,00:10:00,600,6.2,5.4, " etc... Can i make this Csv-string into data? (I have a lot of these from an earlier bad import)
Thank you! Fredrik
2 Commenti
Jan
il 24 Ott 2011
It depends on what "data" means exactly. Please explain the type of the input (string, cell string, test file, MAT file?) and the wanted output explicitely.
Risposta accettata
TAB
il 24 Ott 2011
Text={'2011-08-18,00:10:00,600,1.56188,3.33684,4.328568,2.03864';'2011-08-18,00:20:00,600,7.26988,7.23684,0.328568,8.03864'};
TextLen=length(Text);
NewText=cell(TextLen,2);
Data=zeros(TextLen,5);
for x=1:length(Text)
SplitData=textscan(Text{x},'%s','delimiter',',');
NewText{x}={SplitData{1}{1},SplitData{1}{2}};
Data=(str2double({SplitData{1}{3:end}}));
end
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Cell Arrays 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!