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

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2018년 3월 30일

댓글:

2018년 3월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by