You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: traj_opt7c.m
    path of file: ./repos/quadrotor/traj_planning
    
    the code of the file until where you have to start completion: function X = traj_opt7c(path, total_time, ts)
% Minimum snap trajectory optimization
% by solving 8m linear equations. Assumes constant speed

    
function X = traj_opt7c(path, total_time, ts)
% Minimum snap trajectory optimization
% by solving 8m linear equations. Assumes constant speed
% @author       Yiren Lu
% @email        luyiren [at] seas [dot] upenn [dot] edu
% 
% @input:       path                (m+1) by 3 planning trajectory
%               total_time          total time
% @output       X                   8mx3 solution vector, where
%                                   X(8*(k-1)+1:8*k,d) is the coefficients
%                                   of x_k(t), i.e., 
%                                   x_k(t)=X(8*(k-1)+1:8*k,d)'*[t^3;t^2,t,1]
%                                   where d \in [1,2,3] to indicate dimension xyz
path0 = path;
% generate the trajectory here, and decide the total_time
[m,n] = size(path0); % n == 3
% there we set m = m - 1 for convenience
m = m-1;
% there are now in total m+1 points in the path, which seperate the path into
% m subpaths.

% ts(k) = t_{k+1}, e.g. ts(1) = t_0,
% time planning according to the segment length

% ts(m+1) = t_m
% In 7rd order (minimum snap) trajectory optimization, for each subpath there are 
% 8 parameters
% x_k(t) = sum_{i=1}^8 c_{k,i-1}*t^{i-1} 
%    for k = 1..(m-1)

% X contains the parameters
X = zeros(8*m,n);
A = zeros(8*m, 8*m, n);
Y = zeros(8*m,n);

for i = 1:n
   A(:,:,i) = eye(8*m)*eps;
   % constraint 1: x_k(t_k) = x_{k+1}(t_k) = p_k, where p_k is a
   % waypoint
   % x_k(t) = sum_{i=1}^8 c_{k,i-1}*t^{i-1} 
   %    for k = 1..(m-1)
   % e.g.   x_1(t_1) = x_2(t_1) = p_1;
   % there are in total 2*(m-1) constraints
   idx = 1; % constraint counter
   for k = 1:(m-1)
       A(idx, 8*(k-1)+1:8*k, i) = [ts(k+1)^7, ts(k+1)^6, ts(k+1)^5, ts(k+1)^4, ts(k+1)^3, ts(k+1)^2, ts(k+1), 1];
       Y(idx,i) = path0(k+1,i);
       idx = idx + 1;
       A(idx, 8*(k)+1:8*(k+1), i) = [ts(k+1)^7, ts(k+1)^6, ts(k+1)^5, ts(k+1)^4, ts(k+1)^3, ts(k+1)^2, ts(k+1), 1];
       Y(idx,i) = path0(k+1,i);
       idx = idx + 1;
   end