using polyval(a,x)
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Sean de Wolski
le 15 Août 2011
It doesn't
fzero(@(x)6*x^3+4*x^2-5/12*x^3-7*x^2+3*x+8.2892,pi)
0 commentaires
Paulo Silva
le 15 Août 2011
%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 commentaires
Voir également
Catégories
En savoir plus sur Function Creation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!