How to properly write e^(sin(x)^3) x^6-2x^4-x^

I have it written this way :
f= @(x)(exp((sin(x))^3)+x^6-2*x^4-x^3-1);
but it is not giving me the correct answer when it gets run through my code. THANKS!

Answers (1)

You need to use Vectorization (link):
f= @(x)(exp(sin(x).^3) + x.^6 - 2*x.^4 - x.^3 - 1);
x = linspace(-pi, pi);
plot(x, f(x))
grid

Tags

Asked:

on 28 Mar 2018

Edited:

on 28 Mar 2018

Community Treasure Hunt

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

Start Hunting!