Optional Function input arguments

6 ビュー (過去 30 日間)
Ahmed Abdulla
Ahmed Abdulla 2020 年 6 月 7 日
編集済み: Matt J 2020 年 6 月 7 日
I am writing a function and basically it does a set of command on the inputted matrices, How can i specify that the user can enter any number of matrices as inputs and the code will perform the command on all of them. So if three matrices are inputted then the code runs for the 3 and if 20 are inputted the commands are done for all 20. I hope i explained my problem well enough
  1 件のコメント
Ahmed Abdulla
Ahmed Abdulla 2020 年 6 月 7 日
for example i would like to get the highest 3 numbers by considered all data from the inputted matrices but i dont know how many matrices the user is going to input.

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

採用された回答

Matt J
Matt J 2020 年 6 月 7 日
編集済み: Matt J 2020 年 6 月 7 日
You would use varargin,
function theFunction(varargin)
for i=1:numel(varargin)
matrix=varargin{i};
...
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by