I want to read a gcode-file into matlab.. The format looks something like below…
;LAYER:0M107G0 F9000 X89.19 Y90.68 Z0.30;TYPE:SKIRTG1 F1200 X89.40 Y91.83 E0.05822G1 X89.67 Y92.97 E0.11703G1 X90.01 Y94.10 E0.17553
I want to read the G0 and G1 commands, describing positions.. The input not complete and may not hold all coordinates in all lines.. The output I'm looking for is a array (or a table) with the X, Y and Z movements, with a NaN or zero when values are missing.. So something like this:
89.19 90.68 0.3089.40 91.83 NaN89.67 92.97 NaN90.01 94.10 NaN
I've been trying to use regexp, but can't really wrap my head around it..
I've already made a loop based reader, that splits the strings and examines if with IF-statements, but this is timeconsuming, as these files may hold hundred of thousands of commands….
Best Answer