What changed about matlab and tabs in a recent update?
7 views (last 30 days)
Show older comments
I am using (fairly simple) code to cut out part of a tsv file. This code is working in R2018b but not in R2020b:
line_cell = strsplit(tlines{i}(), '\t');
Where tlines is an array of strings with tabs such as
tlines{4}() = 'g1 : 14.203 79.931 50.598'
Now R2018b give me
1×5 cell array
{'g1'} {':'} {'14.203'} {'79.931'} {'50.598'}
As it should. But R202b give me:
1×1 cell array
{'g1→:→14.203→79.931→50.598'}
What changed in the updates and how can you get the old (correct) functionality back?
Accepted Answer
Jan
on 29 Jan 2021
Edited: Jan
on 29 Jan 2021
I cannot confirm your observation:
str = {sprintf('g1\t:\t14.203\t79.931\t50.598')}
% str = 1×1 cell array
% {'g1→:→14.203→79.931→50.598'}
strsplit(str{1}, '\t')
% 1×5 cell array
% {'g1'} {':'} {'14.203'} {'79.931'} {'50.598'}
This is the output in Matlab Online 2020b.
0 Comments
More Answers (1)
Steven Lord
on 29 Jan 2021
tlines = sprintf('g1\t:\t14.203\t79.931\t50.598')
split(tlines, '\t') % tlines{4} does not contain the characters \ and t
split(tlines, sprintf('\t')) % but it does contain the tab character
See Also
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!