Remove Curly brackets from string/array - what am I working with?
    10 views (last 30 days)
  
       Show older comments
    
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 Comments
  Image Analyst
      
      
 on 5 Aug 2021
				We have no clue what you're dealing with either.  It looks like a character array, not a table.  Not sure exactly what you're pasting into the command window either but it looks like it might be a cell because it puts braces around it.  Let us help you by attaching your variable in a .mat file
save('answers.mat', 'YourVariable');
Answers (1)
  Rik
      
      
 on 5 Aug 2021
        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})
4 Comments
  Stephen23
      
      
 on 6 Aug 2021
				@Lukas Netzer: was the data provided to you in a .mat file? If not, please upload the original data file.
See Also
Categories
				Find more on Logical 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!



