how to read as a string

1 view (last 30 days)
Sangeetha Marikkannan
Sangeetha Marikkannan on 6 Jan 2016
I need to convert that char into string. I am attaching the profiled data,
0x0B55 0x5000 movf 0x00,w,0 144
0x0B56 0x2600 addwf 0x00,f,0 144
0x0B58 0x3602 rlcf 0x02,f,0 144
0x0B59 0x3603 rlcf 0x03,f,0 144
I need to read the mneumonics alone from each line. Eg. movf from first line, addwf from second line, rlcf from third line.
how to read that words alone as strings
  3 Comments
Walter Roberson
Walter Roberson on 6 Jan 2016
I formatted your Question, but I had to guess about where the line boundaries were.
Sangeetha Marikkannan
Sangeetha Marikkannan on 6 Jan 2016
I tried with textscan it reads as char and it is not a string

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 6 Jan 2016
fid1 = fopen('M:\decompiler\dct.txt','rt');
datacell = textscan(fid1, '%*s%*s%s%*[^\n]', 'delimiter, ' \t');
fclose(datacell);
mnemonics = datacell{1};
This will be a cell array of strings, one string per line. For example mnemonics{2} would be the string from the second line.
However, as I indicated in your other question, a string is a row vector of char, so when I say "cell array of strings" I mean that it will be a cell array of row vectors of char, one row vector per line, and mnemonics{2} would be the row vector of char that is the mnemonic.

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!