automatically cycle through function inputs

11 visualizzazioni (ultimi 30 giorni)
Philip Hoskinson
Philip Hoskinson il 24 Lug 2015
Commentato: Nitai Fingerhut il 30 Mag 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

Risposte (1)

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

Categorie

Scopri di più su Desktop in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by