function [qd,dqd,ddqd]= exampleHelperPolynomialTrajectoryEvaluation(p, time)
    %exampleHelperPolynomialTrajectoryEvaluation evaluates the desired motion
    %
    %   This function evaluates desired position, velocity and acceleration 
    %   based on the given time stamp and the polynomial coefficients of 
    %   the trajectory generated using exampleHelperPolynomialTrajectory.

    %   Copyright 2017 The MathWorks, Inc.
    
    %#codegen
    
    % Assign the time stamp
    t = time;
    dim = size(p,2);
    qd = zeros(dim,1);
    dqd = zeros(dim,1);
    ddqd = zeros(dim,1);
    % Evaluate the desired motion
    for i = 1:dim
            qd(i) = p(1,i)*t.^5+p(2,i)*t.^4+p(3,i)*t.^3+p(4,i)*t.^2+p(5,i)*t+p(6,i);
            dqd(i) = 5*p(1,i)*t.^4+4*p(2,i)*t.^3+3*p(3,i)*t.^2+2*p(4,i)*t.^1+p(5,i);
            ddqd(i) = 20*p(1,i)*t.^3+12*p(2,i)*t.^2+6*p(3,i)*t+2*p(4,i);
    end
end