How to split a strange character in a cell array?

I was tempting using split, strsplit, cell2mat, many ways to split these cells array and take out this 'special character' that is the "enter symbol", i also tried to split with '\r', '\r' '\t', but with not successful result. I need you provide me please a solution. THank you so much. It seems very simple but i am not finding a solution for it. This special character is known as '(U+25AF)' and when i call with {} it appears vertical, when i call it with (), it appears with the enter symbols thjat i need to take out.
%% Code begin
F1=readtable('umtri_2002.xlsx');
p=F1{1,:};
q=F1{2,:};
save('umtri_2002_TEST.mat','p','q')
%%%Output
>> size(p(2))
ans =
1 1
>> p(2)
ans =
1×1 cell array
{'50↵102↵178'}
>> p{2}
ans =
'50
102
178'
>>
Captura.JPG

4 件のコメント

Walter Roberson
Walter Roberson 2019 年 7 月 24 日
Can you attach umtri_2002.xlsx for our testing?
Walter Roberson
Walter Roberson 2019 年 7 月 24 日
Could you clarify what the bottom black and white output is from? The top (color) output is self consistent with the possibility that the character is newline rather than the one you indicate.
Kagan Eröz
Kagan Eröz 2019 年 7 月 28 日
編集済み: Kagan Eröz 2019 年 7 月 28 日
you try to take out only first value, like 50? if i understand you true,
try it with this : p{2}(1,1)
Diego Cuba Zuñiga
Diego Cuba Zuñiga 2019 年 8 月 3 日
Hi Kagan,
I test it but it does not works, it just only takes each element and not converts the string numbers to double:
p{2}(1,1:2) -> it will have the number '50', an it might be everytime leaving one position for not consider the space char.

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

 採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 28 日

1 投票

parts = regexp(p{2}, '\D+', 'split');
parts_numeric = str2double(parts);

1 件のコメント

Diego Cuba Zuñiga
Diego Cuba Zuñiga 2019 年 8 月 3 日
Hi Walter, it really works!, thank you so much. I had made a loop to not accept strange chars but your answer works good.

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

その他の回答 (0 件)

カテゴリ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by