Is MATLAB is automatically concatenating data from a text file?
Show older comments
I have an input line of text that looks like this:
Band ID: 0 AD ID: 43 Scan ID: 0 LRT/HRT: 0 Valid Flag: 0
I’ m using the following regexp command to split the string;
Data = regexp(LineText,’ +’,’split’);
Actual output:
Band ID: 0AD ID: 43Scan ID: 0LRT/HRT: 0Valid Flag: 0
Expected output:
Band ID: 0 AD ID: 43 Scan ID: 0 LRT/HRT: 0 Valid Flag: 0
Where all numerical values are in there own cell. Also note that if the tabs that occur after each number are only spacs, I get the required result.
I don’t believe I’ve seen the regexp function behave in this manner. Is this a case where regexp is choking on the tabs in the text file? Or is my regexp too generic?
Accepted Answer
More Answers (1)
David Sanchez
on 13 May 2013
Is this what you want?
s='Band ID: 0 AD ID: 43 Scan ID: 0 LRT/HRT: 0 Valid Flag: 0';
data= regexp(s,'\t','split')
you will end up with an cell containing the data string.
Categories
Find more on Characters and Strings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!