MATLAB: How to write correct matlab codes in solving equation

solve equation

I tried to used "solve" to solve the equation but got error. Here is what I have tried.
syms x solve(x+2=1,x)
Please help me correct the codes. I would like to work on harder equations and loops commands. Thanks in advance,

Best Answer

Anupan, use
syms x
solve(x+2 == 1,x)