automatically cycle through function inputs

3 Ansichten (letzte 30 Tage)
Philip Hoskinson
Philip Hoskinson am 24 Jul. 2015
Kommentiert: Nitai Fingerhut am 30 Mai 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

Antworten (1)

Fabio Freschi
Fabio Freschi am 24 Jul. 2015
use varargin:
function name(varargin)
for i = 1:nargin
figure(i), plot(varargin{1});
end
end
  2 Kommentare
Philip Hoskinson
Philip Hoskinson am 24 Jul. 2015
Should be varargin{i} instead of {1} ?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB Report Generator finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by