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 Kommentar

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!

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

John D'Errico
John D'Errico am 30 Dez. 2022
Bearbeitet: John D'Errico am 30 Dez. 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 Kommentar

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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Version

R2022b

Gefragt:

am 30 Dez. 2022

Kommentiert:

am 30 Dez. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by