how to split cell array values into two columns?

I've a variable in cell array as
[2.13949546690144;56.9515770543056] [1.98550875192835;50.4110852121618] . . . . . I want to split it into two columns with two decimal-point numbers as
2.13 56.95
1.98 50.41
.
.
.
by removing open, close braces and semicolon such as [ ; ]

Answers (1)

one way:
C = {[2.13949546690144;56.9515770543056]};
A = round([C{:}].'*100)/100
A =
2.1400 56.9500

8 Comments

I've cell array like this
how to do with this?
how to do with this?
that's what I just showed you, did you try?
C = {[2.13949546690144;56.9515770543056];
[2.13949546690144;56.9515770543056];
[2.13949546690144;56.9515770543056];
[2.13949546690144;56.9515770543056]};
C = round([C{:}].'*100)/100
and the answer is,
C =
2.1400 56.9500
2.1400 56.9500
2.1400 56.9500
2.1400 56.9500
it shows the error as
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Are you sure all your cells contain 2x1 vectors? Show me the output for,
C_sz = cell2mat(cellfun(@size,C,'uni',0))
and another thing, instead of attaching a screenshot of very poor resolution, attach your data directly (as an m-file, mat-file or a csv file, use the paperclip icon!)
yes, all cells are 2x1. find the attachment for 2x1 data (aima1). the above code doesnot give correct ans; find its output in (C_sz)
yes, all cells are 2x1...
No, first element is 1x2! Your problem is right there! You somehow changed the first element in the cell array to be a row vector (1x2 size). Probably you tried my solution just for one element and then you wanted to do the rest.
Change it back to 2x1 and try again.
aima1{1} = aima1{1}.';
and then try my solution again,
>> C = round([aima1{:}].'*100)/100
C =
2.1300 56.9500
1.9900 50.4100
1.7100 50.6300
2.0300 50.3000
1.9800 45.0000
2.0300 45.0500
2.0800 45.0700
2.1400 45.0400
...
It works. thank you very much!!.

Sign in to comment.

Asked:

on 5 Dec 2017

Commented:

KL
on 5 Dec 2017

Community Treasure Hunt

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

Start Hunting!