필터 지우기
필터 지우기

using polyval(a,x)

조회 수: 1 (최근 30일)
Dwyane  Wade
Dwyane Wade 2011년 8월 15일
Hi guys please help me I cant seem to figure out how to use polyval(a,x), I need to use it to solve the following problem:
1.) Confirm that 6x^3+4x^2-5/12x^3-7x^2+3x+9=0.7108 when x=2;
please help me. thanks

답변 (2개)

Sean de Wolski
Sean de Wolski 2011년 8월 15일
It doesn't
fzero(@(x)6*x^3+4*x^2-5/12*x^3-7*x^2+3*x+8.2892,pi)

Paulo Silva
Paulo Silva 2011년 8월 15일
%first way to find if the equality is correct
f=@(x) (-5/12+6)*x^3+(-7+4)*x^2+3*x+9;
f(2)
%second way
polyval([-5/12+6 -7+4 3 9],2)
%yet another way that only works if you have the symbolic toolbox
syms x
f=6*x^3+4*x^2-5/12*x^3-7*x^2+3*x+9;
subs(f,x,2)
every way gives the value 47.666666666666664 not 0.7108, so it's not confirmed, the assumption is wrong.
f=@(x) (-5/12+6)*x^3+(-7+4)*x^2+3*x+9;
ezplot(f,[0 4])
hold on
line(xlim,[0.7108 0.7108],'color',[1 0 0])
line([2 2],ylim,'color',[1 0 0])
plot(2,f(2),'o','linewidth',4,'markersize',10)
text(2,f(2),['\leftarrow' 'x=2 and y=' num2str(f(2))],'FontSize',18)
text(2,0.7108,['\leftarrow' 'x=2 and y=' '0.7108'],'FontSize',18)
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2011년 8월 15일
And ezplot makes a pretty picture to confirm:
ezplot(f)
Paulo Silva
Paulo Silva 2011년 8월 15일
yes it does :)

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

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by