how many parameters can accept a function in MATLAB?

My function has 6 parameters and I get an error 'Too many input argument'

답변 (2개)

Walter Roberson
Walter Roberson 2014년 3월 18일

1 개 추천

65500 would be the upper limit.

댓글 수: 4

Is this documented somewhere?
I am not sure now why I said 65500 . I remember that is (or was) the limit for something, but I do not remember what now.
Testing a moment ago,
foo = @(varargin) nargin;
bar = cell(1,100000000);
tic;foo(bar{:}),toc
that worked, but took close to 2 minutes on my system. (I will try again later when I am not maxing out my hard drive moving files around.)
It's probably a sign that something is maybe wrong in your software designing though if you need 65500 input arguments :)
Not necessarily. Remember that the way to efficiently fprintf() a bunch of items with different formats is to put each item into its own cell and then fprintf(fid, format, TheCell{:}) . One should not have to know that there is a magic upper bound beyond which it is needed to break it into pieces.
For example,
str = cellstr( perms('abcde') );
idx = num2cell((1:size(str,1)));
out = [idx; str.'];
fprintf(fid, '%7d: %s', out{:});
One should not have to know that 'abcdefg' could be handled this way but that 'abcdefgh' had to switch strategies due to crossing a magic boundary around 65000 entries.

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

Gaurav Shukla
Gaurav Shukla 2014년 3월 18일

0 개 추천

I have tried with 13 parameters and it worked.
The error that u have mentioned will appear if your calling function is passing more parameters than the called function can receive.
Ex: function Called(Arg1, Arg2) end
function Calling () Called(Arg1,Arg2,Arg3) end

댓글 수: 4

I am trying the same thing. It is similarly showing error "To many input arguments" My calling function and called function have same number of parameters. can anyone suggest anything more which i can check
'Too many input arguments' doesn't mean you cannot create a function with that many parameters, it means you are calling it wrong, but it is a lot easier to tell that if you post your function signature and your calling syntax.
output = stegno(img,msg,enc_key,FileName_msg);//calling syntax
function [J] = stegno(img,msg,enc_key,FileName_msg) //function signature
Thank you Adam my code is now working fine. Still, i don't know what was the error.

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

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

질문:

2014년 3월 18일

댓글:

2016년 10월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by