Dear Erling and Johan, thank you for your answers.
I tried with SCS and it works fine. I'm using MOSEK 8.
I wanted to make an optimizer instead of using optimize, but it seems it isn't possible.
I get the following error message:
Error
using optimizer (line 303)
Parameters are currently only allowed to enter function such as
exp, sin etc as exp(a), sin(b) etc.