Can anyone help me to write Matlab code to plot f(x)=0.1e^-x sin(4x^3) and g(x)= -f(x)

Answers (1)

You left out a few operators, so I did some guessing. This code uses anonymous functions.
f = @(x) 0.1.*exp(-x) .* sin(4*x.^3);
g = @(x) -f(x);
x = linspace(0, 10, 500);
figure(1)
plot(x, f(x), x, g(x))
grid
legend('f(x)', 'g(x)')
The code is straightforward, and all the MATLAB functions and syntax are explained in the documentation.

Asked:

on 12 Aug 2015

Commented:

on 13 Aug 2015

Community Treasure Hunt

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

Start Hunting!