MATLAB Answers

Not enough input arguments

17 views (last 30 days)
Jakub Zbikowski
Jakub Zbikowski on 16 Apr 2021 at 13:27
Commented: Jakub Zbikowski on 16 Apr 2021 at 19:14
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.

Accepted Answer

David Hill
David Hill on 16 Apr 2021 at 13:32
Edited: David Hill on 16 Apr 2021 at 13:33
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 Comments
Jakub Zbikowski
Jakub Zbikowski on 16 Apr 2021 at 19:14
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by