"Error: not enough input arguments" even though all input arguments are in workspace.

1 回表示 (過去 30 日間)
I use the function below and I have all input arguments in the workspace (f as function, x, y). It asks me to define f, x, and y when I press run and when I fill these in it works. This really irritates me!! Thanks in advance.
function [G] = TaylorSeries(f, x, y)
syms x y
G = f;
display(G)
end

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 8 日
When you run a function, MATLAB never looks inside the workspace of the place it was invoked from in order to try to locate variables whose names just happen to match the name of the parameter given in the function definition. You always have to pass the values into the function, such as going to the command line and invoking
f = @(x, y) sin(x) - 2*cos(2*y) + tan(x.*y);
x = 1.234;
y = 8.765;
TaylorSeries(f, x, y)
  2 件のコメント
Zeff020
Zeff020 2017 年 10 月 8 日
Okay, that is helpful!
Karan Gill
Karan Gill 2017 年 10 月 9 日
I suggest reading the help on functions in MATLAB. Otherwise, you will keep running into errors.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by