Not enough input arguments

1 回表示 (過去 30 日間)
Jakub Zbikowski
Jakub Zbikowski 2021 年 4 月 16 日
コメント済み: Jakub Zbikowski 2021 年 4 月 16 日
function y=h(x)
y = 1./sqrt(1+x.^2)+exp(-x/5).*cos(sqrt(1+x.^2))-0.0486;
end
I'm trying to set this as a function and keep on getting this
Not enough input arguments.
Error in h (line 2)
y = 1./sqrt(1+x.^2)+exp(-x/5).*cos(sqrt(1+x.^2))-0.0486;
My maths teachers gets no issues when doing this. Please can someone respond ASAP as I need this for tomorrow.

採用された回答

David Hill
David Hill 2021 年 4 月 16 日
編集済み: David Hill 2021 年 4 月 16 日
y =@(x)1./sqrt(1+x.^2)+exp(-x/5).*cos(sqrt(1+x.^2))-0.0486;%I would just use an anonymous function
x=0:.01:10;
plot(x,y(x));
  5 件のコメント
Steven Lord
Steven Lord 2021 年 4 月 16 日
If you want to make toast in your toaster, you need to put bread in it before you push the lever down. Pushing the lever down without bread in there doesn't do anything useful.
If you want to call your MATLAB function and have it do something, the input argument to your function is the bread. Trying to call the function (push the lever) with no input argument (bread) will error because your function requires that input. Put the bread (input argument) in the toaster (the function) and it will work (assuming your toaster / function was wired correctly.)
If it still doesn't work after you call the function with an input argument, show us the error message you receive and we may be able to suggest how to rewire the function.
Jakub Zbikowski
Jakub Zbikowski 2021 年 4 月 16 日
I'm trying to prepare for a test tomorrow which im resitting after not sitting it cause of this issue.
I enter this code into my editor and get this answer
x=[-1:0.01:3];
y=F(x);
plot(x,y)
Result:
Unrecognized function or variable 'F'.
Error in t6 (line 2)
y=F(x);
I apologise for being a pain but I have nobody else to ask my teacher had a fallout with me and is likely he won't reply.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by