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

4 visualizzazioni (ultimi 30 giorni)
Kanwal Kaur
Kanwal Kaur il 18 Nov 2016
Commentato: dbmn il 18 Nov 2016
what is the difference between A=[]; and A={}; ?

Risposta accettata

dbmn
dbmn il 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 Commenti
Kanwal Kaur
Kanwal Kaur il 18 Nov 2016
means A=[] can store only double values??
dbmn
dbmn il 18 Nov 2016
no. You can still do things like:
>> A=[];
>> A{2}='asdf';
>> class(A)
ans =
cell
without encountering an error

Accedi per commentare.

Più risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by