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!

댓글을 달려면 로그인하십시오.

 채택된 답변

John D'Errico
John D'Errico 2022년 12월 30일
편집: John D'Errico 2022년 12월 30일
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개)

카테고리

제품

릴리스

R2022b

질문:

2022년 12월 30일

댓글:

2022년 12월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by