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 件のコメント

Philip Hoskinson
Philip Hoskinson 2015 年 7 月 24 日
Should be varargin{i} instead of {1} ?
Nitai Fingerhut
Nitai Fingerhut 2019 年 5 月 30 日
yes

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops 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