how to repeat this code for 3 tie intervals??

1 view (last 30 days)
this code is to find the coefficinets of the third order polynomial in a motion planning: function x=pol3interpol(tk,tk1,qk,qk1,dotqk,dotqk1)
A=[1,tk,tk^2,tk^3; 1,tk1,tk1^2,tk1^3; 0,1,2*tk,3*tk^2; 0,1,2*tk1,3*tk1^2];
C=[qk,qk1,dotqk,dotqk1]';
x=inv(A)*C; where: % qk initial joint position % qk1 final joint position % dotqk initial joint speed % dotqk1 final joint speed % tk=initial time % tk1=final time
I can find the values of the coefficines a0, a1,a2,a3 by this code. but how can I repeat it for 3 times for the values above?
q0=[0 2 5];% Initial position qk1=[2 5 0];% Final position dotqk=[0 0 0];% Initial velocity dotqk1=[0 0 0];% Final velocity tk=[0 2 4]; % Initial time tk1=[2 4 6];% Final time

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 19 Sep 2018
Edited: KALYAN ACHARJYA on 19 Sep 2018
A=[1,tk,tk^2,tk^3; 1,tk1,tk1^2,tk1^3; 0,1,2*tk,3*tk^2; 0,1,2*tk1,3*tk1^2];
C=[qk,qk1,dotqk,dotqk1]';
for i=1:3
x=inv(A)*C
end

More Answers (0)

Categories

Find more on Polynomials in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!