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

2 ビュー (過去 30 日間)
Kanwal Kaur
Kanwal Kaur 2016 年 11 月 18 日
コメント済み: dbmn 2016 年 11 月 18 日
what is the difference between A=[]; and A={}; ?

採用された回答

dbmn
dbmn 2016 年 11 月 18 日
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 件のコメント
Kanwal Kaur
Kanwal Kaur 2016 年 11 月 18 日
means A=[] can store only double values??
dbmn
dbmn 2016 年 11 月 18 日
no. You can still do things like:
>> A=[];
>> A{2}='asdf';
>> class(A)
ans =
cell
without encountering an error

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by