What does this mean?

조회 수: 6 (최근 30일)
Nalini Nadupalli
Nalini Nadupalli 2014년 3월 12일
편집: James Tursa 2014년 3월 13일
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

답변 (1개)

James Tursa
James Tursa 2014년 3월 13일
편집: James Tursa 2014년 3월 13일
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.

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by