matlab - Delimiting a text file with inconsistent spacing -


I have a text file filled with sensor data which has the following formats per line:

 < Code> Date: 2014-04-22_09-48-16.547400 Timestamp: 2873652.086362542 Gyro.X: -0.0372661240398884 Gyro.Y: 0.0541165024042130 Gyro. Z: 0.1216094791889191 UserAxcel.x: -0.0201703608036041 UserAccel. Y: -0.0118222190067172 UserAxcel Z: -0.0187157746404409 Gravity .X: -0.9937761425971985 Gravity.Y: -0.0025820778682828 Gravity.Z: -0.1113654002547264   

All I want from the file timestamp, Giyu, acceleration and numerical values ​​for gravity Are there.

I have tried to use space as a delimiter, but I am running into problems because there are two places before each value if the value is positive but only one negative.

So far I have the following, but it is only going to work if there is a place between each value (each value would have to be negative).

  data = textscan (fid, '% * s% * s% * s% * s% f% * s% f% * s% f% * s% f% * s% F% * S% f% * s% f% * s% f% * s% f% * s% f ',' delimiter ',' ');   

Is there a way to do this?

Set options 'MultipleDelimsAsOne' like this:

  string = "Date: 20l4-04-22_09-48-l6k547400 timestamp: 2873652k086362542 GyrokX: -0k037266l240398884 Garo Y: 0.0541165024042130 Gayro. Z: 0.1216094791889191 UserAxcel.x: -0.0201703608036041 UserAxcel Y: -0.0118222190067172 UserExcel Z: -0.0187157746404409 Gravity.x: -0.9937761425971985 Gravity. Y: -0.0025820778682828 Gravity. Z: -0.1113654002547264 '; Data = tecton (string, ... '% * s% * s% * s% * s% * s% f% * s% f% * s% f% * s% f% * s% f% * s % F% * s% f% * s% f% * s% f ', ...' delimiter ',' ',' multiple delays ons', 1);   

A % * s was missing at the beginning of the format string and there was an unnecessary % * s% f format end of the string What I have removed, it produces a cell with 9 selling point values.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -