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

Réponses (1)

Fabio Freschi
Fabio Freschi le 24 Juil 2015
use varargin:
function name(varargin)
for i = 1:nargin
figure(i), plot(varargin{1});
end
end

2 commentaires

Philip Hoskinson
Philip Hoskinson le 24 Juil 2015
Should be varargin{i} instead of {1} ?
yes

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by