open a hex file
이전 댓글 표시
I use the following code to open a hex file (please look at the attachment).
fid = fopen('FileName');
A = fread(fid);
My problem is instead of getting A as a cell containg n*1 (n is the number of rows in the hex file) I get one row of numbers. I would appreciate it if you help me get a result like below:
00 00 00 00 49 40 40 0D
03 00 30 43 C6 02 00 00
A3 6B 74 23 90 47 E4 40
and so on
댓글 수: 1
Azzi Abdelmalek
2013년 10월 16일
Can you post the result you've got? maybe with simple use of reshape function you can get the expected result
채택된 답변
추가 답변 (1개)
Azzi Abdelmalek
2013년 10월 16일
편집: Azzi Abdelmalek
2013년 10월 16일
fid = fopen('file.txt');
A = textscan(fid,'%s %s %s %s %s %s %s %s')
fclose(fid)
A=[A{:}]
arrayfun(@(x) strjoin(A(1,:)),(1:3)','un',0)
댓글 수: 8
Walter Roberson
2013년 10월 16일
Use '%x%x%x%x%x' instead of %s if the numeric form is desired.
Azzi Abdelmalek
2013년 10월 16일
편집: Azzi Abdelmalek
2013년 10월 16일
Post the first samples you've got with
A = fread(fid);
Azzi Abdelmalek
2013년 10월 16일
If the data you've got are like:
A={'00' ;'00' ;'00';'00'; '49'; '40' ;'40' ;'0D'; '03'; '00' ;'30' ;'43'; 'C6'; '02'; '00' ;'00'}
You can make some transformations
out=reshape(A,8,[])'
result=arrayfun(@(x) strjoin(out(x,:)),(1:size(out,1))','un',0)
Azzi Abdelmalek
2013년 10월 16일
편집: Azzi Abdelmalek
2013년 10월 16일
Decimal numbers? please edit your question and make it as clear as possible
Jan
2013년 10월 16일
@Ronaldo: A memory leak? I assume, you mean something completely different.
카테고리
도움말 센터 및 File Exchange에서 Numeric Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!