adjust a txt file and delete some strings from it ?

1 Ansicht (letzte 30 Tage)
mia saam
mia saam am 24 Aug. 2018
Kommentiert: mia saam am 25 Aug. 2018
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?

Akzeptierte Antwort

KSSV
KSSV am 24 Aug. 2018
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 Kommentare
KSSV
KSSV am 25 Aug. 2018
Try the same code...if any error..you are welcome.
mia saam
mia saam am 25 Aug. 2018
thank you so much

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by