automatically cycle through function inputs

3 visualizaciones (últimos 30 días)
Philip Hoskinson
Philip Hoskinson el 24 de Jul. de 2015
Comentada: Nitai Fingerhut el 30 de Mayo de 2019
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

Respuestas (1)

Fabio Freschi
Fabio Freschi el 24 de Jul. de 2015
use varargin:
function name(varargin)
for i = 1:nargin
figure(i), plot(varargin{1});
end
end
  2 comentarios
Philip Hoskinson
Philip Hoskinson el 24 de Jul. de 2015
Should be varargin{i} instead of {1} ?
Nitai Fingerhut
Nitai Fingerhut el 30 de Mayo de 2019
yes

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Report Generator en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by