필터 지우기
필터 지우기

char to hex in file handling

조회 수: 1 (최근 30일)
Nidhi
Nidhi 2013년 10월 18일
편집: Azzi Abdelmalek 2013년 10월 18일
I have a text file with hex values. when I use fgets all the data gets saved in a char array in matlab. Now I want to process this as hex data. i.e. I want to have an array of hex with this data in it How can I do this??
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 18일
Post a sample of your file

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

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 10월 18일
편집: Azzi Abdelmalek 2013년 10월 18일
If your data are imported in this form
str={'0F4 240'
'1E8 480'
'2DC 6C0'
'3D0 900'}
a=regexp(str,'\s','split');
b=reshape([a{:}],size(a{1},2),[])'
you can for example convert to decimal
out=cellfun(@hex2dec,b)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by