Filter löschen
Filter löschen

what is the difference between A=[]; and A={}; ?

7 Ansichten (letzte 30 Tage)
Kanwal Kaur
Kanwal Kaur am 18 Nov. 2016
Kommentiert: dbmn am 18 Nov. 2016
what is the difference between A=[]; and A={}; ?

Akzeptierte Antwort

dbmn
dbmn am 18 Nov. 2016
One initializes the variable as a double (or array of doubles) and the other as a cell (or a cell array)
>> A=[];
>> class(A)
ans =
double
and
>> B={};
>> class(B)
ans =
cell
  2 Kommentare
Kanwal Kaur
Kanwal Kaur am 18 Nov. 2016
means A=[] can store only double values??
dbmn
dbmn am 18 Nov. 2016
no. You can still do things like:
>> A=[];
>> A{2}='asdf';
>> class(A)
ans =
cell
without encountering an error

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by