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: Murat_codaMatrix.m
    path of file: ./repos/MuRAT/bin
    
    the code of the file until where you have to start completion: function AQc_i                   =...
    Murat_codaMatrix(modvQc,K_grid,r_grid,flag,origin,sections)
% function AQc_i                   =...
%     Murat_codaMatrix(modvQc,origin,sections,flag,K_grid,r_grid)
%
% CREATES the coda attenuation inversion matrix and plots the corresponding
%   kernels
%
% Input parameters:         
%    modvQc:                velocity model for grid
%    K_grid:                kernel from Murat_kernels
%    r_grid:                grid from Murat_kernels
%    flag:                  if turned to 1 creates the figure
%    origin:                origin of the grid
%    sections:              sections of the figure
%
% Output parameters:
%    AQc_i:                 coda inversion matrix

    
function AQc_i                   =...
    Murat_codaMatrix(modvQc,K_grid,r_grid,flag,origin,sections)
% function AQc_i                   =...
%     Murat_codaMatrix(modvQc,origin,sections,flag,K_grid,r_grid)
%
% CREATES the coda attenuation inversion matrix and plots the corresponding
%   kernels
%
% Input parameters:         
%    modvQc:                velocity model for grid
%    K_grid:                kernel from Murat_kernels
%    r_grid:                grid from Murat_kernels
%    flag:                  if turned to 1 creates the figure
%    origin:                origin of the grid
%    sections:              sections of the figure
%
% Output parameters:
%    AQc_i:                 coda inversion matrix

% Nodes of the kernel model space
xK                              =   unique(r_grid(:,1));
yK                              =   unique(r_grid(:,2));
zK                              =   sort(unique(r_grid(:,3)),'descend