I wonder how to get MATLAB read an event file (generated by Neuroscan) in MATLAB. I tried load, csvread, dlmread. None worked. The data includes 5 columns of numbers and one column of words. I do not need the words, though. I can open it by notepad or export it to excel and then apply text to column. Thank you.

 Respuesta aceptada

Star Strider
Star Strider el 30 de Mzo. de 2018

1 voto

See if importdata (link) or readtable (link) will work.

6 comentarios

Elaheh
Elaheh el 30 de Mzo. de 2018
Editada: Star Strider el 30 de Mzo. de 2018
Readtable reads the content but it changes the format to a table with a header, etc., which is not compatible with the later sections of the code. I do not need the header and ' ' .
Trial Resp Type Correct Latency Stim_Resp
_______ ______ ______ _________ _________ ___________
'-----' '----' '----' '-------' '-------' '---------'
'3' '-1' '1' '0' '66' 'Stim'
Star Strider
Star Strider el 30 de Mzo. de 2018
In importdata, you can specify headerlinesIn (link) to skip the header lines, and specify the name-value pair 'HeaderLines' (link) in readtable.
If you use readtable, use the table2array (link) function to convert it to a homogeneous array.
NOTE There is nothing specific about a ‘.dat’ file, so there is no specific function to import one. The importdata and readtble functions are sufficiently robust to deal with most unknown file types and formats.
Experiment to get the result you want.
Elaheh
Elaheh el 30 de Mzo. de 2018
I used A=readtable(fileName); B= table2array(A); B(1,:)=[]; %delete the first row. C = cell2mat(B) % But this function does not convert B, which is a set of cells to ordinary data. What did I do wrong? Other parts work fine. Thank you.
Star Strider
Star Strider el 30 de Mzo. de 2018
My pleasure.
Your ‘B’ cell could be string data. Experiment with:
Bmtx = str2double(B);
That has worked for me in the past.
Elaheh
Elaheh el 30 de Mzo. de 2018
It works. Thank you so much.
Star Strider
Star Strider el 30 de Mzo. de 2018
As always, my pleasure.
If my Answer helped you solve your problem, please Accept it!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 30 de Mzo. de 2018

Comentada:

el 30 de Mzo. de 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by