arrays - Split a matlab column into several columns? -
i have .txt file when loaded puts data:
'a: -379 g: 277 ' 'a: -422 g: 291 ' 'a: -361 g: 217 ' into single column cell, i've tried getting work importdata('.txt''') etc, trying other peoples ideas far have come empty handed. due not understanding how of functions work enough.
as can guessed need data sorted 4 columns can access 2 sets of values example:
1 2 3 4 <- column a: -379 g: 277 a: -422 g: 291 a: -361 g: 217
you can use textscan solve parsing.
fid = fopen('text_43254785.txt'); data = textscan(fid, '%s%f%s%f', 'delimiter',' ', 'multipledelimsasone',1); fclose(fid); the format specifier '%s%f%s%f', indicating row of [strings, number, string, number]. used 'delimiter',' ', 'multipledelimsasone',1 treat multiple spaces single delimiter. result is
>> data{1} ans = 'a:' 'a:' 'a:' >> data{2} ans = -379 -422 -361 from can on project.
edit: updated use pastebin example.
Comments
Post a Comment