-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompute_R.m
More file actions
31 lines (30 loc) · 1.24 KB
/
compute_R.m
File metadata and controls
31 lines (30 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
%---------------------------------------------------------
% Author : Mazen Alamir
% CNRS, UNiversity of Grenoble-Alpes
% Gipsa Lab. Last modification March 2017
%---------------------------------------------------------
%--------------------------------------------------------------------------
% This function compute the parametrization matrix R used in the
% expression p=R*p_r where p is the original piece-wise control profile
% while p_r is the vector of reduced parametrization.
%--------------------------------------------------------------------------
function R=compute_R(Ifree,Np,nu)
coder.allowpcode('plain');
Ifree(1)=1;
nr=length(Ifree);
R=zeros(Np*nu,nr*nu);
for i=1:Np,
if (i==1),
R(1:nu,1:nu)=eye(nu);
elseif (i>=Ifree(nr)),
R((i-1)*nu+1:i*nu,(nr-1)*nu+1:nr*nu)=eye(nu);
else
ji=find(Ifree<=i, 1, 'last' );
R((i-1)*nu+1:i*nu,nu*(ji-1)+1:nu*ji)=...
(1-(i-Ifree(ji))/(Ifree(ji+1)-Ifree(ji)))*eye(nu);
R((i-1)*nu+1:i*nu,nu*ji+1:nu*(ji+1))=...
(i-Ifree(ji))/(Ifree(ji+1)-Ifree(ji))*eye(nu);
end
end
return
%--------------------------------------------------------------------------