not enough input argument error

4 次查看(过去 30 天)
when I put( [1×128 double], 'E') as input argument it says that "Error using double. Not enough input argument. " What's wrong with it ?

采纳的回答

Image Analyst
Image Analyst 2020-6-3
If your function is called MyFunc() and it expects two variables, a 1x128 double vector and a single character, then you need to pass that, not the word double. When it sees "double" it's expecting to call the double() function which needs a variable to make into a double class.
dblVec = rand(1, 128); % A 1 x 128 vector of doubles
ch = 'E'; % A single character vector.
results = MyFunc(dblVec, ch)
  4 个评论
Maria
Maria 2020-6-3
I ran it on command window here
Image Analyst
Image Analyst 2020-6-3
Like I said, you have to pass in something for the first argument. What do you want to pass it? How about just random numbers, like this:
>> r = rand(1, 128); % Or whatever you want.
>> scales(r, 'E')

请先登录,再进行评论。

更多回答(1 个)

Steven Lord
Steven Lord 2020-6-3
It seems like you're trying to call a function using the description of a variable from the Workspace window rather than the variable itself.
It's like you tried to define a variable named x that is a double array of size 1x10.
>> x = 1:10;
>> whos x
Name Size Bytes Class Attributes
x 1x10 80 double
In order to call a function like sin on it, you don't pass in the description of the variable:
>> sin(1x10 double)
sin(1x10 double)
Error: Invalid expression. Check for missing multiplication operator, missing or
unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead
of parentheses.
Instead you pass the variable itself. Note that after I do that, y becomes a 1x10 double just like x was and is. Each element of y is the sine of the corresponding element of x: y(1) is the sine of x(1), y(2) the sine of x(2), etc.
>> y = sin(x);
>> whos x y
Name Size Bytes Class Attributes
x 1x10 80 double
y 1x10 80 double

类别

Help CenterFile Exchange 中查找有关 Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by