How to define a function of one variable in MATLAB

How to define a function of one variable in MATLAB


function y=fun(x)
expression;
end



How to draw function image of y = asinx. Y = xsinx, y = exp ^ (- x) * SiNx, y = exp ^ (- 100x) * SiNx with MATLAB


syms x
ezplot(sin(x))
figure
ezplot(x*sin(x))
figure
ezplot(exp(-x)*sin(x))



The usage and function of exp in MATLAB


LN
Exponential function based on e



How to solve the equation x + 0.8 * SiNx pi = 0 in MATLAB


SYMS X; s = solve (x + 0.8 * sin (x) - pi, 'x') s = 3.1415926535897932384626433832795 this can be solved, I run the results as above, need to pay attention to the solution of the function is a symbolic equation, so in advance to define the variable SYMS X; there is the use of the solve command to get the precision