![]() MATLAB codeĮxample 3: Reconsider Example 1 at the top of the page. ![]() If all variables are given numerical values, the answer is a number in MATLAB, not “Maple”.Įxample 2: Let us compare simple MATLAB and “Maple” codes which both evaluate the expression y = (x 3 + 2) sec x at x = 0.123. It is of the form ans=eval(S) where S is a symbolic expression for which at least one of its symbolic variables has just been given a value. The result g is still a symbolic variable or symbolic constant in “Maple”.Įxample 1: Consider a function of the two Cartesian coordinates f(x, y) =Ĭhange to polar coordinates using x = r cos θ, y = r sin θ and then determine the value of f at an arbitrary point on the unit circle r = 1.į=subs(f,) Īn alternative is to use the eval command. Then you can use the general subs command g=subs(f,old,new) which in our cases would be g=subs(f,x,c) or g=subs(f,x,x0). Suppose you have a symbolic expression f which includes the symbol x and you wish to substitute for x another symbol c or a numerical value x0. The keyfunction subs (which stands for substitute) is used to replace symbolic variables with either new symbolic variables or with acutal values. Variable substitution and expression evaluation: subs, eval You can use the syntax subs(sM) to substitute the symbolic matrix variables and matrix functions in sM with their assigned values in the MATLAB workspace and. syms a b c x define symbolic math variables > f sym('ax2 + bx + c') From now on we can use the f symbol to represent the given function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |