automatically cycle through function inputs

I want to simplify a function so that I don't have to create multiple loops for each input:
function [] = NAME( a,b,c,d,e,g,e,h,th,sg,r etc..)
for i = (number of inputs??)
figure(i)
plot( automatically cycle through inputs)
end

답변 (1개)

Fabio Freschi
Fabio Freschi 2015년 7월 24일

0 개 추천

use varargin:
function name(varargin)
for i = 1:nargin
figure(i), plot(varargin{1});
end
end

댓글 수: 2

Should be varargin{i} instead of {1} ?
yes

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2015년 7월 24일

댓글:

2019년 5월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by