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: pointwise_KM_STP_optimization.m
    path of file: ./repos/OPEN_FPE_IFT/Functions_v5-MATLAB
    
    the code of the file until where you have to start completion: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This function performs the pointwise optimization of Kramers-Moyal coefficients 
% $D^{(1,2)}\left(u_r,r\right)$ at each scale and value of velocity increment to minimize possible 
% uncertainties in the absolute values of the Kramers-Moyal coefficients. The object of this 
% optimization is to find the best Fokker-Planck equation to reproduce the conditional PDF's as 
% these are the essential part of the Markov process. This optimization procedure is proposed in 
% \cite{kleinhans2005iterative,Nawroth2007,Reinke2018} and it includes the reconstruction of the 
% conditional probability density functions $p\left(u_{r'} | u_r \right)$ via the short time 
% propagator \cite{Risken}. The optimization procedure systematically changes 
% $D^{(1,2)}\left(u_r,r\right)$ until the error function is minimized.
%
% Arguments IN
% evaluated = struct array calculated in the function 'conditional_moment'
% scal = A scale number which needs to be optimized
% increment_bin = number of bins
% markov = markov length in number of samples
% data = filtered data
% Fs = Acquisition/Sampling Frequency in Hz
% tol = Optimization: Tolerance of the range of Kramers-Moyal coefficients in % 
%       It is the percentage(For Ex: 0.1 for 10 percent or 0.2 for 20 percent)of D1 or D2 
%       within these limit which you want to optimize these coeffcients D1 & D2
% m_data = mean of the data
% taylor_L = Taylor length scale in meters
% test_opti = weather to plot or not ==> 'Plot? 1=Yes, 0=No'
% multi_point = weather to do multi-point analysis or not 1=Yes, 0=No
% condition = condition for multi-point analysis
% tol_point = This input is for multipoint statistics
% min_events = minimum number of events
% k = Multi-point number of point condition
%
% Arguments OUT
% evaluated = a modified/updated struct 'evaluated' array after the optimization at each scale and at each bin for D1 & D2 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [evaluated]=pointwise_KM_STP_optimization(evaluated,scal,increment_bin,markov,data,Fs,tol,m_data,taylor_L,test_opti,multi_point,condition,tol_point,min_events,k,norm_ur,norm_r,save_path,save_name) 
% Initial D1 and D2 before optimization 
clear x0
x0(1,1:2*sum(evaluated(scal).x_bin_not_nan))=[(evaluated(scal).D1(evaluated(scal).x_bin_not_nan)),(abs(evaluated(scal).D2(evaluated(scal).x_bin_not_nan)))];       

tau1            =   evaluated(scal).r_short_sample;
tau2            =   evaluated(scal).r_samp;
x_bin_not_nan   =   evaluated(scal).x_bin_not_nan;
D1              =   evaluated(scal).D1;
D2              =   evaluated
    
function performs the pointwise optimization of Kramers-Moyal coefficients 
% $D^{(1,2)}\left(u_r,r\right)$ at each scale and value of velocity increment to minimize possible 
% uncertainties in the absolute values of the Kramers-Moyal coefficients. The object of this 
% optimization is to find the best Fokker-Planck equation to reproduce the conditional PDF's as 
% these are the essential part of the Markov process. This optimization procedure is proposed in 
% \cite{kleinhans2005iterative,Nawroth2007,Reinke2018} and it includes the reconstruction of the 
% conditional probability density functions $p\left(u_{r'} | u_r \right)$ via the short time 
% propagator \cite{Risken}. The optimization procedure systematically changes 
% $D^{(1,2)}\left(u_r,r\right)$ until the error function is minimized.
%
% Arguments IN
% evaluated = struct array calculated in the function 'conditional_moment'
% scal = A scale number which needs to be optimized
% increment_bin = number of bins
% markov = markov length in number of samples
% data = filtered data
% Fs = Acquisition/Sampling Frequency in Hz
% tol = Optimization: Tolerance of the range of Kramers-Moyal coefficients in % 
%       It is the percentage(For Ex: 0.1 for 10 percent or 0.2 for 20 percent)of D1 or D2 
%       within these limit which you want to optimize these coeffcients D1 & D2
% m_data = mean of the data
% taylor_L = Taylor length scale in meters
% test_opti = weather to plot or not ==> 'Plot? 1=Yes, 0=No'
% multi_point = weather to do multi-point analysis or not 1=Yes, 0=No
% condition = condition for multi-point analysis
% tol_point = This input is for multipoint statistics
% min_events = minimum number of events
% k = Multi-point number of point condition
%
% Arguments OUT
% evaluated = a modified/updated struct 'evaluated' array after the optimization at each scale and at each bin for D1 & D2 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [evaluated]=pointwise_KM_STP_optimization(evaluated,scal,increment_bin,markov,data,Fs,tol,m_data,taylor_L,test_opti,multi_point,condition,tol_point,min_events,k,norm_ur,norm_r,save_path,save_name) 
% Initial D1 and D2 before optimization 
clear x0
x0(1,1:2*sum(evaluated(scal).x_bin_not_nan))=[(evaluated(scal).D1(evaluated(scal).x_bin_not_nan)),(abs(evaluated(scal).D2(evaluated(scal).x_bin_not_nan)))];       

tau1            =   evaluated(scal).r_short_sample;
tau2            =   evaluated(scal).r_samp;
x_bin_not_nan   =   evaluated(scal).x_bin_not_nan;
D1              =   evaluated(scal).D1;
D2              =   evaluated(scal).D2;
eD1             =   evaluated(scal).eD1;
eD2             =   evaluated(scal).eD2;
x_mean_bin      =   evaluated(scal).x_mean_bin;
y_mean_bin      =   evaluated(scal).y_mean_bin;


if multi_point==1
    [incr1,incr2]  = Increment_point(tau1,tau2,data,condition(k),tol_point);
elseif multi_point==0
    [incr1,incr2]  = Increment(tau1,tau2,data);
end