‘sym’ command is a very useful command in Matlab® to create unknown variables to use in various polynomial and mathematical applications. ‘syms’ is also used in this way.
We explained these codes with very basic examples below in the MatLab® command window. Just take a look at the examples below.
>> p=x.^2+3.*x+5; Undefined function or variable 'x'. >>
In normal, if you write a polynomial like above into the Matlab® command window, you will face an error like above that says ‘Undefined function or variable ‘x’. ‘. Because ‘x’ is not defined as a variable. And in Matlab®, all the variables must have values.
>> x = sym('x'); p=x.^2+3.*x+5; >>
If you look at the example above, there is no problem with ‘x’. Because ‘x’ is defined as a symbolic variable, which has no exact value. We created a polynomial that can be operable with further factorizations or other kinds of mathematical operations.
YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!
>> syms x y z p=x.^2+y+z; >>
Use of ‘syms’ command is easier than ‘sym’ command in Matlab®. If you take a look at the syntax above, you just need to type the required symbolic variables, and functions after that.
You can use these symbolic variables wherever you want in Matlab®.
As you understand from above, the use of ‘sym’ and ‘syms’ commands in Matlab® is very simple.
Do not forget to leave your comments and questions below about the use of ‘sym’ and ‘syms’ commands in Matlab® below. If you want further coding examples about ‘sym’ and ‘syms’ commands in Matlab®, inform us in the comments.
This article is prepared for completely educative and informative purposes.
Your precious feedbacks are very important to us.