行列を構築するための完全にベクトル化された方法を次に示します - ループなし、いいえarrayfun:    
PPR=[0     2     3     5     6     8];
AI=[ 0    0.7854    0.5236    0.3142    0.2618    0.1963];
M = ones(length(PPR),PPR(end)+1); #% allocate proper sized matrix of ones
r=1:length(PPR)-1; #% row indices for 1 element past the end of each row vector
c=PPR(1:end-1)+2; #% corresponding column indices
linear_index = sub2ind(size(M),r,c); #% create linear index from r,c
M(linear_index)=nan; #% set those elements to NaN
M2 = cumsum(M,2)-1; #% use cumsum to propagate the NaN values
M3 = bsxfun(@times,M2,AI'); #%'#multiply each row by the appropriate AI value
xp = sin(M3)+1 #% take the sine of the matrix
わかりやすくするために、一連の一時変数を使用しました。ワークスペースが散らかるのを避けたい場合は、複数回使用されないことが多いため、それらを避けることができます。
また、これにより、他の値を指定していないマトリックスが NaN で埋められます。これらを他のデフォルト (ゼロや 1 など) に置き換えたい場合は、最後に行うのは非常に簡単です。