Import txt file into matlab using programically

I have data in txt file as shown below:
ffffffffffffffffffffffffffff
ffffffffffffffffffffffffffff
01234efefabcdeffffffffffffff
ffffffffffffabcdeabcdeffffff
abcdefabcdefabcdefabcdefabcd
abcdffffffefefefefbabadededf
1234dace56778445dcfacedbebbf
abcdfedfedabce34127432ffedab
now these data i have to take in m file by importing txt file into matlab.For that what matlab code should be written.....
Thanks

댓글 수: 4

Jan
Jan 2012년 9월 11일
This question is far to general to be answered. Please add any details by editing the question.
It is still not clear what form the data is in. Is the data a continuous string of digits, like you've indicated, or is it separated into numbers by spaces, line breaks, commas, etc.? Can you post the first few lines of the file into your question? Also, can you tell us what your desired output for those lines looks like?
Jan
Jan 2012년 9월 12일
And what is the desired output? A String or are these characters 4 Byte hex-encoded signed integers?
Tinkul
Tinkul 2012년 9월 12일
It is continuous string of digits.There is no commas,spaces etc.Output should be same as in the txt file.

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

 채택된 답변

Jan
Jan 2012년 9월 12일
편집: Jan 2012년 9월 12일

0 개 추천

fid = fopen(FileName, 'r');
if fid == -1, error('Cannot open file'); end
S = fread(fid, Inf, '*char');
fclose(fid);
Or to use a Matlab function:
S = fileread(FileName);

추가 답변 (2개)

K
K 2012년 9월 11일

0 개 추천

I've used the command textread really successfully with .txt files where the columns of numbers were separated by spaces or tabs. The command looked something like this:
textread('Nameoftextfile.txt','%f %f %f','headerlines',12);
Try searching for textread in the Matlab help to get details for your specific application.

카테고리

도움말 센터File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기

질문:

2012년 9월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by