Deblank an empty vector

1 回表示 (過去 30 日間)
Edward Huang
Edward Huang 2019 年 7 月 19 日
編集済み: Edward Huang 2019 年 7 月 19 日
Let's say we have the following code:
v = zeros(1,0);
w = [];
isequal(v,w);
isequal(deblank(v),w);
While both v and w are considered "empty", they are not exactly the same. I guess this is because v is a vector while the other is not. What confuses me is the deblank function which, according to doc, it is to "remove trailing blanks". And there is no further explanation why deblank an empty vector will result in [ ].
Can any one explain it to me, please? Thanks in advance.

採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 19 日
"Because Reasons"
The preservation of the shape of empty vectors is not suggested anywhere in the documentation, so this is not a bug.
The function copies to output the columns starting from the first column which has a non-whitespace, and ending with the last column that has a non-whitespace. Empty inputs have no such columns, so nothing gets copied, including not the exact size of the emptiness.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by