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: LQtune.m
    path of file: ./repos/AutomationShield/matlab/examples/BoBShield
    
    the code of the file until where you have to start completion: function [R, X, U] = LQtune(x)
%define LQR
Ts=0.01;
load('myModel.mat')
csystem=ss(model.A,model.B,model.C,model.D);
%ssest, so sumom alebo bez, ale rovnako v simulacii ako v modeli. 

    
function [R, X, U] = LQtune(x)
%define LQR
Ts=0.01;
load('myModel.mat')
csystem=ss(model.A,model.B,model.C,model.D);
%ssest, so sumom alebo bez, ale rovnako v simulacii ako v modeli. 
%fok vagy radian? 
dsystem=c2d(csystem,Ts,'zoh');
A=dsystem.A;
B=dsystem.B;
C=dsystem.C;
D=dsystem.D;
%integrator
 AI = [A, zeros(2, 1); -C, 1];
 BI = [B; 0];
 CI = [C, 0];
 
 

% Penalizacne matice
R=x(1);
Q=diag([ x(2), x(3), x(4)]);
%penalizacna matica, zosilnenie;
[K,P]= dlqr(AI,BI,Q,R);
 
%load measurede data
load('dataPidAll.mat')
Um=dataAll(:,3);
Ym=dataAll(:,2);
Ref=dataAll(:,1); %reference
%select "the interesting section"
 Ref=Ref(500:5500)';
 
 N=length(Ref);
 t=1:N;

X0=[0.01; 0];
X=X0;
R=Ref./1000;
XI = 0; % Integrator state

% Este mozno toto by sa oplatilo pozerat.
% yshift = 0.0546; % Detrend