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.

 Accepted Answer

Star Strider
Star Strider on 30 Mar 2018

1 vote

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

6 Comments

Elaheh
Elaheh on 30 Mar 2018
Edited: Star Strider on 30 Mar 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 on 30 Mar 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 on 30 Mar 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.
My pleasure.
Your ‘B’ cell could be string data. Experiment with:
Bmtx = str2double(B);
That has worked for me in the past.
Elaheh
Elaheh on 30 Mar 2018
It works. Thank you so much.
Star Strider
Star Strider on 30 Mar 2018
As always, my pleasure.
If my Answer helped you solve your problem, please Accept it!

Sign in to comment.

More Answers (0)

Tags

Asked:

on 30 Mar 2018

Commented:

on 30 Mar 2018

Community Treasure Hunt

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

Start Hunting!