フィルターのクリア

Why Does numel() Accept More than One Argument?

2 ビュー (過去 30 日間)
Paul
Paul 2024 年 5 月 24 日
コメント済み: Paul 2024 年 5 月 24 日
@doc:numel indicates that the function accepts only a single argument. But it can be called with more than one argument and it returns a result.
which numel(rand(3),rand(5))
built-in (/MATLAB/toolbox/matlab/elmat/@double/numel) % double method
numel(rand(3),rand(5)) % return numel of the second argument?
ans = 25
which numel(rand(3),rand(5),rand(4))
built-in (/MATLAB/toolbox/matlab/elmat/@double/numel) % double method
numel(rand(3),rand(5),rand(4)) % returns ?
ans = 400
  2 件のコメント
DGM
DGM 2024 年 5 月 24 日
編集済み: DGM 2024 年 5 月 24 日
Paul
Paul 2024 年 5 月 24 日
Thanks for the link.

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

採用された回答

Animesh
Animesh 2024 年 5 月 24 日
Hey @Paul,
When the numel function in MATLAB is called with more than one input argument, it returns the product of number of elements in the parameters after the first.
Hence the following code snippet returns 400, i.e. "numel ( rand ( 5 ) ) * numel ( rand ( 4 ) )":
numel(rand(3),rand(5),rand(4))
ans = 400
numel(rand(5)) * numel(rand(4))
ans = 400
You can refer the following MATLAB Answer for more information:

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by