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 commentaire

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!

Connectez-vous pour commenter.

 Réponse acceptée

John D'Errico
John D'Errico le 30 Déc 2022
Modifié(e) : John D'Errico le 30 Déc 2022
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 commentaire

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!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Produits

Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by