Creating a function with varying numbers of input parameters

조회 수: 15 (최근 30일)
Hi
I am writing a function to plot data for me in different ways. I would like to decide in which way to plot the data when i call the function. For example, if i write
myfunction(f,k,'stem')
then I would like the result to be a stem plot. If i were to write
myfunction(f,k)
then the result should be different, but nevertheless work.

채택된 답변

Abdolkarim Mohammadi
Abdolkarim Mohammadi 2020년 9월 29일
You should use Variable-length input argument list using varargin().

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by