필터 지우기
필터 지우기

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 CenterFile Exchange에서 Get 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