Effacer les filtres
Effacer les filtres

How to use Matlab to write a function

1 vue (au cours des 30 derniers jours)
NIANNIAN
NIANNIAN le 2 Nov 2014
Modifié(e) : NIANNIAN le 12 Nov 2014

Réponse acceptée

Stelina
Stelina le 2 Nov 2014
a short .mfile with the solution

Plus de réponses (1)

Star Strider
Star Strider le 2 Nov 2014
Your detailed solution is waiting for you here.
  3 commentaires
Star Strider
Star Strider le 2 Nov 2014
Thank you!
NIANNIAN
NIANNIAN le 3 Nov 2014
Modifié(e) : NIANNIAN le 3 Nov 2014
To clarify, I did not ask for answer here. I apologize that there is something wrong with the way I post my questions here. I post the question just because to explain what I was stuck with. I did put my effort in my homework!
The following is my code: function the_maclaurin_series_expansion x=linspace(0,(3*pi)/2); y=cos(x);
macxp=1-x.^2/factorial(2)+x.^4/factorial(4)-x.^6/factorial(6)+x.^8/factorial(8)
plot(x,macxp) hold on plot(x,y,'--') hold on xlabel('x'); ylabel('cos(x)'); legend('Series expansion','True'); title('Series expansion of the cosine function'); grid on hold off
er=(sum(abs(y-macxp)))/sum(abs(y)) disp(er)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming 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!

Translated by