how do I properly format using the syms function in matlab

I am new to matlab and after reading the tutorials for factoring, solving and simplifying algebraic operations, I'm still not getting it. I beleive I have a formatting issue. Do I need to put parenthisis around the x's?
syms x
c=factor(2*x^4+x^3-19*x^2-9*x+9);
fprintf('Problem 3a answer is :',c)
syms x
d =solve (2*x^4+x^3-19*x^2-9*x+9==0,x);
fprintf('Problem 3b answer is :',d)
syms x
e =simplify 3*(x-2y+4(3x+7y-81));
fprintf('Problem 3b answer is:', e)

1 个评论

Thanks, I used fprint on previous problems but I realize that was when I needed to approximate to 6 decimal places. Using disp, the answers popped write up!

请先登录,再进行评论。

 采纳的回答

Do you need parens around the x? NO.
syms x
c=factor(2*x^4+x^3-19*x^2-9*x+9);
fprintf('Problem 3a answer is :',c)
Problem 3a answer is :
Anyway, why do you think you need to use fprintf here? And even if you did use fprintf, that tool needs a format spec. You might do this:
disp('Problem 3a answer is :'),disp(c)
Problem 3a answer is :
Or, perhaps this:
disp(['Problem 3a answer is : ',char(c)])
Problem 3a answer is : [x - 3, 2*x - 1, x + 3, x + 1]

1 个评论

Thanks, I used fprint on previous problems but I realize that was when I needed to approximate to 6 decimal places. Using disp, the answers popped write up!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Multidimensional Arrays 的更多信息

产品

版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by