I have a very simple question: I’m trying to simplify the expression x + x to get the answer 2x in MATLAB but I’m having a hard time figuring out the proper format and I don’t know what to search in the documentation files for an answer.
I have a very simple question: I’m trying to simplify the expression x +
Share
EDIT:
From the comments below, it looks like you need the symbolic toolbox. A basic example can be found in this answer. Once
xis set to be a symbolic variable,x+xshould give you2*x.Original answer:
Your question, as it stands, is not very clear. I’ll interpret your question to mean the following:
In MATLAB, arithmetic operations need to be explicitly stated. The operator for scalar multiplication is
*and you would write the above as2*x. Here is the documentation for the various arithmetic operations, and their rules & syntaxes. For the most part, if you’re familiar with linear algebra, you’ll find MATLAB pretty easy to use.If I’m mistaken and you meant something else, please edit your question to clarify (and/or leave a comment here) and I’ll update my answer.