# Value Calculation With ‘subs()’ Command In MatLab®

Here, we explain a very useful command available in Matlab®. This command is named ‘subs()’ If you have a very complex equation, and you need to calculate a specific value of this equation according to a value of the variable of this equation; you can use the ‘subs()’ command.

Here, we explain how to use the ‘subs()’ command in Matlab® with a very basic example that is executed in the command window. Check it out.

On this post

## How To Use ‘subs()’ Command In Matlab®?

``````>> syms a
y = a-3 + (3/(a-1)) - (2/(a+9));
z = subs(y,a,a^2+3)
d = subs(z, a, 2)

z =

3/(a^2 + 2) - 2/(a^2 + 12) + a^2

d =

35/8

>> ``````

As you see in the example above, we created a symbolic variable ‘a’ with ‘syms’ command. And, we defined our ‘complex’ equation with this variable which is assigned to ‘y’.

Consider a situation that we want to see the new value of function ‘y’ with the new value of ‘a’ equals ‘a^2+3’. So, we used the ‘subs()’ command to do it.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

We defined the ‘subs()’ command by typing three elements inside it. The first element is the name of the function which is ‘y’ in the example above. The second one is the variable of this function, which is ‘a’ in the example above. Then the third one is as you guessed, the new value ”a^2+3′. You can see the first answer ‘z’.

We can use this ‘z’ function to calculate its value for ‘a=3’. So, we defined another ‘subs()’ for it. You can see the second answer ‘d’ for this new value.

## Conclusion

As you see that, the ‘subs()’ command is a very easy-to-use and very useful command in Matlab® that you can calculate various kinds of calculations.

Do not forget to leave your comments and questions below about the use of the ‘subs()’ command in Matlab® below.

If you want further coding examples about the ‘subs()’ command in Matlab®, inform us in the comments.