필터 지우기
필터 지우기

automatically cycle through function inputs

조회 수: 4 (최근 30일)
Philip Hoskinson
Philip Hoskinson 2015년 7월 24일
댓글: Nitai Fingerhut 2019년 5월 30일
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일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by