MATLAB Answers

Remove Curly brackets from string/array - what am I working with?

조회 수: 34(최근 30일)
Lukas Netzer
Lukas Netzer 2021년 8월 5일
댓글: Stephen 2021년 8월 6일
I have acutally no clue what I am working with.
I got tables containing i.e. the following:
'[[0, 145, 0], [145, 169, 1], [169, 1693, 3], [1693, 1708, 1], [1708, 2729, 3], [2729, 2779, 0]]'
when I paste it in the cmd-window it looks like that:
{'[[0, 145, 0], [145, 169, 1], [169, 1693, 3], [1693, 1708, 1], [1708, 2729, 3], [2729, 2779, 0]]'}
I actually would like to access the numerical values, but don't know how - can I somehow remove those brackets and then access them?
Thanks for your help!
  댓글 수: 2
Lukas Netzer
Lukas Netzer 2021년 8월 6일
thank you for your comment - I am working on my master thesis and never had a matlab course before - I'm not a mathematican nor am I a programmer - I am really just learning by doing, but obviously struggling.
it looks like that:
part of the data is attached - hope this works!
best regards,
Lukas

댓글을 달려면 로그인하십시오.

답변(1개)

Rik
Rik 2021년 8월 5일
Your data seems to be a cell containing JSON data:
data={'[[0, 145, 0], [145, 169, 1], [169, 1693, 3], [1693, 1708, 1], [1708, 2729, 3], [2729, 2779, 0]]'};
jsondecode(data{1})
ans = 6×3
0 145 0 145 169 1 169 1693 3 1693 1708 1 1708 2729 3 2729 2779 0
  댓글 수: 4
Stephen
Stephen 2021년 8월 6일
@Lukas Netzer: was the data provided to you in a .mat file? If not, please upload the original data file.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by