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

 Réponse acceptée

dbmn
dbmn le 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 commentaires

Kanwal Kaur
Kanwal Kaur le 18 Nov 2016
means A=[] can store only double values??
no. You can still do things like:
>> A=[];
>> A{2}='asdf';
>> class(A)
ans =
cell
without encountering an error

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by