Not enought input arguments

조회 수: 1 (최근 30일)
Martin Kavka
Martin Kavka 2020년 5월 28일
댓글: Martin Kavka 2020년 5월 29일
I know that a lot of people must ask this but I am trying to figure this out and I dont know what to do.
I have this function and in workspace I have 2 arrays first is cas and second is outputs01, and both are arrays of 101 numbers, and this function should show me time of minimal and maximal number from outputs01. Time is stored in cas. And it jsut keeps showing me error posted below the code. I really dont know what to do, I have tried many things. Thanks for any help.
function [minn,max1] = minmax(outputs01,cas)
val = min(outputs01);
ind = find(val==outputs01);
minn = cas(ind);
val1 = max(outputs01);
ind1 = find(val==outputs01);
max1 = cas(ind1);
end
Not enough input arguments.
Error in minmax (line 4)
val = min(outputs01);
  댓글 수: 5
Brent Kostich
Brent Kostich 2020년 5월 28일
편집: Brent Kostich 2020년 5월 28일
You are just typing:
minmax
That is equivalent to calling the function with no input arguments, or:
minmax()
Instead you need to type this into the command line:
[min,max] = minmax(outputs01, cas)
You defined the function to expect two input arguments, any more or less will throw an error.
Furthermore, you don't actually need use the 'find' function. The 'min' and 'max' functions allow you to yield the index directly. See the documentation for either of those functions, or the following example:
[~,ind] = min(outputs01)
Martin Kavka
Martin Kavka 2020년 5월 29일
yeah it helped thank you guys a lot.

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

답변 (1개)

madhan ravi
madhan ravi 2020년 5월 28일
Use function in a proper way. Please see the documentation on how to call a function properly.
  댓글 수: 1
madhan ravi
madhan ravi 2020년 5월 28일
[minn,max1] = minmax(outputs01,cas) % Paste this in command window

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

카테고리

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

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by