본문 바로가기

Matlab

Datatype


>> Logical = 1>0;

Character = 'Hello';

Numeric = [1 2 ; 3 4];

Cell = {[1 2] , [1 2 3], 'Hello'};

Structure.a = 1;

>> whos

  Name           Size            Bytes  Class      Attributes

  Cell           1x3               230  cell                 

  Character      1x5                10  char                 

  Logical        1x1                 1  logical              

  Numeric        2x2                32  double               

  Structure      1x1               132  struct               


logical은 각각 1비트가 아닌 1바이트를 차지한다.

char는 각각 2바이트(unicode)를 차지, \0은 없다.

structure는 .으로 참조.

cell은 matrix와 달리 {}로 다른 종류의 데이터타입 저장 .

 >> Cell = { 5  [1 2 ; 3 4] 'Hello' }

Cell = 

    [5]    [2x2 double]    'Hello'

>> Cell(1,2) 

ans = 

    [2x2 double]

>>Cell{1,2}

ans =

     1     2

     3     4

>>Cell{1,2}(2,1) 

ans =

      3


 function handles(함수를 변수로)

>>  h = @plot; 

>> h(1:10); 

 test.m


function test(a)

    plot(a(0 : 0.01 : 10));

end


>> test(@sin)

>> test(@cos)



'Matlab' 카테고리의 다른 글

Bernoulli trials and binomial probabilities  (0) 2014.05.12
Pseudo-random number generation  (0) 2014.05.12
Plot  (0) 2013.12.23
Control Flow  (0) 2013.12.23
M-file  (0) 2013.12.23