필터 지우기
필터 지우기

Varargin - mistake in my example

조회 수: 2 (최근 30일)
Gennaro Arguzzi
Gennaro Arguzzi 2017년 5월 13일
답변: Andrei Bobrov 2017년 5월 13일
Hi everyone, I wrote the following function:
function [x] = ingressi_arbitrari(varargin)
x=0;
for k=1:nargin
x=x+1;
end
end
Why if I run a=ingressi_arbitrari([2 3]) in the command window, the result is a=1 instead of a=2 (I choose two input arguments)?
Thank you very much.

채택된 답변

Walter Roberson
Walter Roberson 2017년 5월 13일
You only have one input argument, that happens to be length 2. If you had
a=ingressi_arbitrari([2 3], [7; 1; 8; 5])
then you would have two input arguments, the first length 2 and the second length 4

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2017년 5월 13일
use:
ingressi_arbitrari(2,3)

카테고리

Help CenterFile Exchange에서 Manage Products에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by