not enough input argument error

1 回表示 (過去 30 日間)
Maria
Maria 2020 年 6 月 3 日
回答済み: Steven Lord 2020 年 6 月 3 日
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 ?
  1 件のコメント
madhan ravi
madhan ravi 2020 年 6 月 3 日
We are not magicians , show the code.

サインインしてコメントする。

採用された回答

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by