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: RunPOMDP.m
    path of file: ./repos/POMDP
    
    the code of the file until where you have to start completion: 
function output = RunPOMDP(input,params)


learningRate    = params(1);
extraRewardVal	= params(2);
beliefNoiseSTD = params(3);

stimTrials = input.stimTrials;
extraReward = input.extraRewardTrials;


% set run numbers
iterN = 21;  % model values are averaged over iterations (odd number)
trialN = length(stimTrials);


% initialise variables, for speed
action						= cell(trialN,iterN);
QL								= zeros(trialN,iterN);
QR								= zeros(trialN,iterN);
predictionError		= zeros(trialN,iterN);
    
function output = RunPOMDP(input,params)


learningRate    = params(1);
extraRewardVal	= params(2);
beliefNoiseSTD = params(3);

stimTrials = input.stimTrials;
extraReward = input.extraRewardTrials;


% set run numbers
iterN = 21;  % model values are averaged over iterations (odd number)
trialN = length(stimTrials);


% initialise variables, for speed
action						= cell(trialN,iterN);
QL								= zeros(trialN,iterN);
QR								= zeros(trialN,iterN);
predictionError		= zeros(trialN,iterN);


for iter = 1:iterN
	
	% initalise Q values for each iteration
	QLL(1,:) = 1;
	QRR(1,:) = 1;
	QLR(1,:) = 0;
	QRL(1,:) = 0;
	
	% start model
	for trial=1:trialN
		
		
		% set contrast
		currentStim = stimTrials(trial);
		
		% add sensory noise
		stim_withnoise  = currentStim + beliefNoiseSTD * randn;
		
		
		% calculate belief
		Belief_L = normcdf(0,stim_withnoise,beliefNoiseSTD);
		Belief_R = 1 - Belief_L;
		
		
		%initialise Q values for this iteration
		QL(trial,iter) = Belief_L*QLL + Belief_R*QRL;
		QR(trial,iter) = Belief_L*QLR + Belief_R*QRR;
		
		
		% action <-- max(QL,QR)
		if QL(trial,iter) > QR(trial,iter)
			
			action{trial,iter} = 'left';
			
		elseif QL(trial,iter) < QR(trial,iter)
			
			action{trial,iter} = 'right';
			
		else
			
			if rand >= 0.5
				action{trial,iter} = 'right';
			else
				action{trial,iter} = 'left';
			end