What changed about matlab and tabs in a recent update?

3 ビュー (過去 30 日間)
Timotheus Berg
Timotheus Berg 2021 年 1 月 29 日
コメント済み: Timotheus Berg 2021 年 1 月 29 日
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?
  1 件のコメント
Jan
Jan 2021 年 1 月 29 日
What is the meaning uf the "()" in: tlines{i}() ?

サインインしてコメントする。

採用された回答

Jan
Jan 2021 年 1 月 29 日
編集済み: Jan 2021 年 1 月 29 日
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.

その他の回答 (1 件)

Steven Lord
Steven Lord 2021 年 1 月 29 日
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 件のコメント
Timotheus Berg
Timotheus Berg 2021 年 1 月 29 日
Sry I'm dumb.
I'm using a library with a lot of dependencies and one of them hat a strsplit function...

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeString Parsing についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by