MATLAB: Quick question. Am i doing this right

homeworkmathmathamaticsSymbolic Math Toolbox

Hey guys,
so I'm in my first year and first week of engineering and messing around doing some questions we've been given to try out.
so, I'm doing ok so far. Hit and miss but generally I can find a way to get the right answer. Not sure why I'm getting this answer for this question though. Please help.
Q: Define variables X and Y as X = 5.1 and Y = 4.2 and evaluate, 3/4 xy – 7x/y^2 + sqrt(xy)
(The / are fractions rather than a divided by) The following is my answer
A: X =5.1; Y=4.2;
sym(3/4) * x * y – sym(7 * x / y^2) + sqrt(x * y)
When i do that, the result i get is not straightforward. Rather it is, (3*2^(1/2)*119^(1/2))/10 + 58973/4200
not sure where I'm going wrong. Thanks in advance

Best Answer

Ordinary evaluation of an expression doesn't require sym. Simply
(3/4) * x * y - 7 * x / y^2 + sqrt(x * y)
will evaluate the expression to give you a single number. Normally you would assign this to a variable, for example:
z = (3/4) * x * y - 7 * x / y^2 + sqrt(x * y)
Note, though, that variable names are case-sensitive, so you have to be consistent. Either use upper case X and Y or lower-case x and y for both the assignments and the expression.
Related Question