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.

 采纳的回答

Star Strider
Star Strider 2018-3-30

1 个投票

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

6 个评论

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'
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.
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.
It works. Thank you so much.
As always, my pleasure.
If my Answer helped you solve your problem, please Accept it!

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by