Importing Matrix from text or csv files

I have a large matrix that I'd like to import, preferably in one command into a few different Matlab variables. I have been attempting to use "importdata" but it doesn't seem to respect the row headers because many of them are numeric (CUSIPS). I have a file that's roughly 1000x500 with one row of column headers and one column of row headers. Does anyone know how I can import this data all at once? If not all at once, what's the easiest way to go about importing it all when I'm not quite sure how many columns I will have in total? In the end I should have two arrays of column headrers (text) and a matrix of numerical data.
Thanks a lot, Brian

 채택된 답변

the cyclist
the cyclist 2012년 2월 21일

0 개 추천

Personally, I like the readtext() function from the FEX for mixed-type files: http://www.mathworks.com/matlabcentral/fileexchange/10946.
This is not to be confused with the MATLAB function textread(), whose help file has the quote "If the file contains any text data, an error is produced." :-)

댓글 수: 4

Brian
Brian 2012년 2월 27일
Sorry for the delayed response. This function works beautifully. It imports the entire data set into a cell from which I can create my matrix and character arrays.
Brian
Brian 2012년 3월 21일
I am getting the data to import into one large cell where I have actual text data in column 1 and dates in row1. No matter what I try I can't get the dates to be converted to something that Matlab will recognize. Any idea how to do this? My dates are imported but have no '' around them.
Thanks,
Brian
the cyclist
the cyclist 2012년 3월 21일
I think you should launch a new question on this, and add more detail around what the text that you are importing looks like (possibly with an example).
Brian
Brian 2012년 4월 19일
Thanks - just did so here ->http://www.mathworks.com/matlabcentral/answers/36006-import-from-txt-or-csv

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

제품

질문:

2012년 2월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by