Why are the results of the size function different from the whos function Size?
2 ビュー (過去 30 日間)
古いコメントを表示
Why are the results of the size function different from the whos function Size?
Here is an example:
>> excelstring = strfind('ABC DUMP.txt','.xls')
excelstring =
[]
>> size excelstring
ans =
1 11
>> whos excelstring Name Size Bytes Class Attributes
excelstring 0x0 0 double
0 件のコメント
採用された回答
James Tursa
2011 年 6 月 15 日
Doing this:
size excelstring
Is equivalent to doing this:
size('excelstring')
Whenever you invoke a function without the parens, the remainder of your inputs are taken to be literal string(s).
1 件のコメント
Matt Fig
2011 年 6 月 15 日
As described here:
http://www.mathworks.com/help/techdoc/ref/syntax.html
This is called command-function duality.
その他の回答 (1 件)
the cyclist
2011 年 6 月 15 日
Because the syntax for what you wanted is
>> size(excelstring)
Looks like your syntax is giving the size of the string 'excelstring', rather than that of the variable named excelstring.
1 件のコメント
Chirag Gupta
2011 年 6 月 15 日
To explain further, size excelstring is equivalent to asking MATLAB to compute size('excelstring').
MATLAB takes the arguments as strings if they are not passed in parenthesis ()
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!