Home » All Programs » Creating Symbolic Variables With ‘sym’ And ‘syms’ Commands In MatLab®

Creating Symbolic Variables With ‘sym’ And ‘syms’ Commands In MatLab®

‘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.

‘sym’ Command In MatLab®

>> 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’ Command In 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®. 

Conclusion

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.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *


Please

leave feedback ?

( For the post )

ASK THE MECHANICALLAND

COMMUNITY


We are always open to your feedback to improve ourselves and the quality of our content! If you have any suggestions, thoughts, or criticism, please let us know. We are trying to improve our blog with constructive feedback. We are aware of how valuable your feedback is for our future development, and we will carefully read all your comments. Thank you in advance!