Calling function with varying number of parameters in Matlab

前端 未结 2 522
甜味超标
甜味超标 2020-12-31 20:21

I am using symbolic toolbox to generate a matlab function. But the number of input to the generated function is varying with the number of objects that I need (e.g., number

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 21:17

    You can create functions with variable numbers of input arguments with varargin.

    function fun(varargin)
    a = cell2mat(varargin); % works only if arguments indeed only consists of scalars.
    
    % your code comes hereafter
    

提交回复
热议问题