Hi. I'm a Matlab newbie. I would like to read in a file where the lines have different formats, as below.
% Coordinates
% Code ID X Y
C 101 0.001 0.001 C 102 1.002 0.002 C 103 1.003 1.003 C 104 0.004 1.004% Distances
% Code ID From To Dist
D 201 101 103 1.417 D 202 102 104 1.414
If the first character is C, use…
A = textscan(fid,'%c %d %f %f')
If the first character is D, use…
A = textscan(fid,'%c %d %d %d %f')
After, I'd like to assign the data to structs (c.id, c.x, c.y, d.id, d.from, d.to, d.dist), but first I think I just need to get it scanned in. Is it possible to apply some logic to reading the file? Thank you.
Best Answer