f = pwd;cd(erase(mfilename('fullpath'),extractAfter(mfilename('fullpath'),'matlab_code'))); addpath(genpath(pwd)); cd(f);


if exist('C','var')    
    if isvalid(C.v)
        if isvalid(C.v.fig), delete(C.v.fig); end
        delete(C.v);
    end
    delete(C)
    clear C
end

if exist('M','var')
    delete(M)
    if ~isvalid(M)
        clear M
    end
end
% start Model
if ~exist('M','var') 
    
    img = 'terminator.jpg';
    p = erase(mfilename('fullpath'),extractAfter(mfilename('fullpath'),'matlab_code'));
    p = fullfile(p,'Model','img');
    mlsGrid = [10, 10];
    mlsType = 'Similarity';
    loadCtrlPoints = 1;
    M = Model(p,img,mlsGrid,mlsType,loadCtrlPoints);
    
end
clear mlsGrid mlsType loadCtrlPoints img f p 

C = Controller2(M);