OpenMATB icon indicating copy to clipboard operation
OpenMATB copied to clipboard

Suggestions about processing the log-file in MATLAB/R?

Open Sophieforever opened this issue 2 years ago • 3 comments

Dear all,

I tried to analyse the generated log-file in MATLAB and R. However, I am having a problem to read in the entire dataset.

For instance, some columns contain different kind of information (numbers/text) and are therefore not loaded properly.

Do you have by chance any suggestions on how to read the entire log-file in Matlab or R with out data loss?

Best, Sophie

Sophieforever avatar Jul 22 '22 08:07 Sophieforever

Hi @Sophieforever , Could you post a sample of the log file you want to process and explain more precisely what is the unexpected behavior with this example ? Best, Benoît

benoitvalery avatar Jul 22 '22 08:07 benoitvalery

Here is an example file: Example.log

For instance, when trying to read the data in Matlab using the readtable()-function, it looks like that: image

Some of the information is lost or recognized as a Nan, I think because there is mixed data in one column (text and numbers).

In R I tried to use the read.table() and read_log() functions, but got similar results. Do you know a trick on how to read the file without data loss? Or maybe another program in which one can analyse the log-files?

Sophieforever avatar Jul 22 '22 09:07 Sophieforever

The readtable function in Matlab might have an option to handle several formats. For instance, see if

readtable('Example.log','Format','auto')

resolve the NaN thing. See the documentation of this function for more options. Then you will have to parse the Var7 column by hand depending on what you want to achieve.

Do not hesitate to filter the log file, to retain only the rows you need (for instance the STATE lines).

With these two steps, you might be able to convert the remaining lines into floats, for further processing.

benoitvalery avatar Jul 22 '22 10:07 benoitvalery

Do not hesitate to re-open the ticket if you get into more troubles.

benoitvalery avatar Dec 12 '22 08:12 benoitvalery