MATLAB Answers

Minor mistake Writing a function but error

1 view (last 30 days)
Jhonie Habimana
Jhonie Habimana on 25 Nov 2020
Commented: Walter Roberson on 25 Nov 2020
Hello just a quick question, I am writing a code but an error keeps poping up for the function I entered
By any chance would you know why it keeps coming up as a red warning
f=@ (1./x)+(sqrt(x).*exp(x));

  0 Comments

Sign in to comment.

Answers (1)

VBBV
VBBV on 25 Nov 2020
%if true
f = @(x) (1/x)+(sqrt(x)*exp(x))

  2 Comments

VBBV
VBBV on 25 Nov 2020
Use function handle to invoke a function or specify a variable used in the expression terms
Walter Roberson
Walter Roberson on 25 Nov 2020
f = @(x) (1./x)+(sqrt(x).*exp(x))
as the original was vectorized

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!