Why am I getting this error? 'Unrecognized function or variable 'poly2str'.'

Every time I use the 'poly2str' function Matlab is saying its an unrecognized function or variable. I am following video tutorials on matlab basics and the code I am using has been provided by my lecturer, and he uses the exact same code in the video without any problems. The only thing is that the videos could be outdated as they are a few years old, so maybe is that the issue?
figure(2); clf reset
x2=-3:.1:5;
p=poly([-1 -2]);
px = polyval(p,x2);
plot(x2,px,'r:')
title(['Plot of polynomial with coefficients ',num2str(p)])
xlabel('x')
ylabel(poly2str(p,'x'))

 채택된 답변

I first tried poly2sym, and although it works, it does not print out correctly with anything I tried. (It prints as 3*x + x^2 + 2.)
So I went with the obvious:
figure(2)
x2=-3:.1:5;
p=poly([-1 -2]);
px = polyval(p,x2);
plot(x2,px,'r:')
title(['Plot of polynomial with coefficients ',num2str(p)])
xlabel('x')
polysym = poly2sym(p,sym('x'));
ylabel(sprintf('x^2 + %dx + %d',p(2:3)))
I left in the poly2sym call in case you want to experiment with it.
.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Animation에 대해 자세히 알아보기

제품

릴리스

R2019b

태그

질문:

2020년 7월 31일

댓글:

2020년 7월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by