What changed about matlab and tabs in a recent update?

7 views (last 30 days)
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
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.

More Answers (1)

Steven Lord
Steven Lord on 29 Jan 2021
tlines = sprintf('g1\t:\t14.203\t79.931\t50.598')
tlines = 'g1 : 14.203 79.931 50.598'
split(tlines, '\t') % tlines{4} does not contain the characters \ and t
ans = 1x1 cell array
{'g1→:→14.203→79.931→50.598'}
split(tlines, sprintf('\t')) % but it does contain the tab character
ans = 5x1 cell array
{'g1' } {':' } {'14.203'} {'79.931'} {'50.598'}
  1 Comment
Timotheus Berg
Timotheus Berg on 29 Jan 2021
Sry I'm dumb.
I'm using a library with a lot of dependencies and one of them hat a strsplit function...

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!