MATLAB Function Finds The Derivative and Evaluates at Point A
    5 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
My task is to write a MATLAB function that calculates the derivate of a polynomial, represented in vector form, and then also evaluates the derivative at a point a. So far I have the code to find the derivative, I just do not know how to evaluate at a from there. Note: f(x) = 3x^4 - 5x^2 -6x can be represented as P = [3, 0, -5, -6, 0]. Here is what I have so far:
function [PP,PPa] = ex5(P,a)
%
% where PP = the derivative of P
%            PPa = the derivative of P evaluated at a
n = length(P);
PP = (n-1:-1:1).*P(1:n-1);
PPa = %not sure what to put here
4 commentaires
  Steven Lord
    
      
 le 9 Déc 2020
				If I gave you a polynomial like  and asked you to evaluate it (by hand, with pencil and paper) at x = 4 how would you do that? List the steps, not just the answer. Can you adapt your pencil and paper technique into MATLAB code and use it to evaluate p = [1 2 3] at x = 4;?
 and asked you to evaluate it (by hand, with pencil and paper) at x = 4 how would you do that? List the steps, not just the answer. Can you adapt your pencil and paper technique into MATLAB code and use it to evaluate p = [1 2 3] at x = 4;?
 and asked you to evaluate it (by hand, with pencil and paper) at x = 4 how would you do that? List the steps, not just the answer. Can you adapt your pencil and paper technique into MATLAB code and use it to evaluate p = [1 2 3] at x = 4;?
 and asked you to evaluate it (by hand, with pencil and paper) at x = 4 how would you do that? List the steps, not just the answer. Can you adapt your pencil and paper technique into MATLAB code and use it to evaluate p = [1 2 3] at x = 4;?Use polyval not as part of your implementation but to check your answer during development, comparing the result of your code to the results from polyval.
Réponses (1)
  James Tursa
      
      
 le 9 Déc 2020
        
      Déplacé(e) : Sabin
    
 le 15 Jan 2023
  
      @Sophie:  You might investigate the .^ operator (element-wise raise-to-power).
1 commentaire
Voir également
Catégories
				En savoir plus sur Polynomials 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!



