adjust a txt file and delete some strings from it ?

조회 수: 1 (최근 30일)
mia saam
mia saam 2018년 8월 24일
댓글: mia saam 2018년 8월 25일
hello, if I have a txt file like this:
p 1 = 1 B9 7 ;
p 2 = 2 E3 D ;
p 3 = 3 12 F ;
p 4 = 4 C8 2 ;
and I want to delete p num.= (i.e.everything before the =) from each line then concatenate all the lines together to get (1B972E3D3 12F4C82). can you please help me?

채택된 답변

KSSV
KSSV 2018년 8월 24일
fid = fopen('data.txt') ;
S = textscan(fid,'%s %d %s %d %s %s') ;
fclose(fid) ;
% pick the required cells
S = S(4:end) ;
% join them
S = strcat(num2str(S{1}),S{2},S{3}) ;
% remove zeros if any
S(2:2:end) = [];
% single line
[S{:}]
  댓글 수: 3
KSSV
KSSV 2018년 8월 25일
Try the same code...if any error..you are welcome.
mia saam
mia saam 2018년 8월 25일
thank you so much

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by