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

 Accepted Answer

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 Comments

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

Sign in to comment.

More Answers (0)

Tags

Asked:

on 18 Nov 2016

Commented:

on 18 Nov 2016

Community Treasure Hunt

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

Start Hunting!