What does this mean?

11 views (last 30 days)
Nalini Nadupalli
Nalini Nadupalli on 12 Mar 2014
Edited: James Tursa on 13 Mar 2014
I defined a Cell array as following
C =
'one' 'two' 'three'
[ 1] [ 2] [ 45]
Change 1: Changed the values of the 2nd row as follows >> C(2,:)={{1,2},{3,4},{5,6}}
and Got
C =
'one' 'two' 'three'
{1x2 cell} {1x2 cell} {1x2 cell}
Change 2: if I changed the values as the following
>> C(2,:)={[1,2],[3,4],[5,6]}
C =
'one' 'two' 'three'
[1x2 double] [1x2 double] [1x2 double]
Can someone please explain what is the difference between the results of change 1 and change 2?
Thanks a lot in advance

Answers (1)

James Tursa
James Tursa on 13 Mar 2014
Edited: James Tursa on 13 Mar 2014
Change 1:
Each element of the 2nd row is a cell array. And each of those cell arrays has two elements (1x2 dimension). Each of those two elements is in and of itself a MATLAB double variable. The way you have constructed it, you have six separate double variables, [1], [2], [3], [4], [5], [6], that are stored inside of three cell arrays that are themselves stored inside of a single cell array.
Change 2:
Each element of the 2nd row is a double array. And each of those doubles arrays has two elements (1x2 dimension). The way you have constructed it, you have three separate double variables (each 1x2), [1 2], [3 4], [5 6], that are stored inside of a single cell array.

Categories

Find more on Matrices and Arrays 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!