diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m
index fb909f8893c558156758f6e34214725fec399d6b..7fa1716f6f1c5fbaa13aef2f968dc04f9532bc8a 100644
--- a/matlab/PosteriorIRF_core1.m
+++ b/matlab/PosteriorIRF_core1.m
@@ -194,7 +194,7 @@ while fpar<B
     end
     if MAX_nirfs_dsgevar
         IRUN = IRUN+1;
-        [fval,info,junk1,junk2,junk3,junk3,junk4,PHI,SIGMAu,iXX] =  dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+        [fval,info,~,~,~,~,~,PHI,SIGMAu,iXX] =  dsge_var_likelihood(deep',dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
         dsge_prior_weight = M_.params(strmatch('dsge_prior_weight', M_.param_names));
         DSGE_PRIOR_WEIGHT = floor(dataset_.nobs*(1+dsge_prior_weight));
         SIGMA_inv_upper_chol = chol(inv(SIGMAu*dataset_.nobs*(dsge_prior_weight+1)));
diff --git a/matlab/WriteShockDecomp2Excel.m b/matlab/WriteShockDecomp2Excel.m
index d0ecd7cc47ee5f96f9a0d611d501b09fa7af3ecd..cdce0ec48dbaacb004eb38aa6554d0cbb20b441a 100644
--- a/matlab/WriteShockDecomp2Excel.m
+++ b/matlab/WriteShockDecomp2Excel.m
@@ -93,7 +93,7 @@ for j=1:nvar
     d0={};
     z1 = squeeze(z(i_var(j),:,:));
     if screen_shocks
-        [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
+        [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
         labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
         zres = sum(z1(isort(17:end),:),1);
         z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
diff --git a/matlab/annualized_shock_decomposition.m b/matlab/annualized_shock_decomposition.m
index 5f5e086748cb9d350bec989f1c91f58cb32ca7ae..63400893fd06de554f64bd9b2f2ffdfba15b9bce 100644
--- a/matlab/annualized_shock_decomposition.m
+++ b/matlab/annualized_shock_decomposition.m
@@ -128,7 +128,7 @@ if realtime_==0
         myopts=options_;
         myopts.plot_shock_decomp.type='qoq';
         myopts.plot_shock_decomp.realtime=0;
-        [z, junk] = plot_shock_decomposition(M_,oo_,myopts,[]);
+        [z, ~] = plot_shock_decomposition(M_,oo_,myopts,[]);
     else
         z = oo_;
     end
@@ -287,7 +287,7 @@ if isstruct(aux)
     yaux=aux.y;
 end
 
-[nvar , nterms, junk] = size(z);
+[nvar, nterms, ~] = size(z);
 for j=1:nvar
     for k =1:nterms
         ztmp = squeeze(z(j,k,min((t0-3):-4:1):end));
diff --git a/matlab/bksupk.m b/matlab/bksupk.m
index 64de63b8b6e37c5c239dad2d0fcc6b278202b696..cca78d7f617b57f00c30925da3417bf26a973222 100644
--- a/matlab/bksupk.m
+++ b/matlab/bksupk.m
@@ -40,7 +40,7 @@ irf = icc1+(options_.periods-1)*ny ;
 d1 = zeros(options_.periods*ny,1) ;
 
 ofs = (((options_.periods-1)*ny+1)-1)*jcf*8 ;
-junk = fseek(fid,ofs,-1) ;
+[~] = fseek(fid,ofs,-1) ;
 c = fread(fid,[jcf,ny],'float64')';
 
 d1(ir) = c(:,jcf) ;
@@ -52,7 +52,7 @@ while i <= M_.maximum_lead || i <= options_.periods
     irf1 = selif(irf,irf<=options_.periods*ny) ;
 
     ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
-    junk = fseek(fid,ofs,-1) ;
+    [~] = fseek(fid,ofs,-1) ;
     c = fread(fid,[jcf,ny],'float64')' ;
 
     d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
@@ -64,7 +64,7 @@ end
 while i <= options_.periods
 
     ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
-    junk = fseek(fid,ofs,-1) ;
+    [~] = fseek(fid,ofs,-1) ;
     c = fread(fid,[jcf,ny],'float64')' ;
 
     d1(ir) = c(:,jcf)-c(:,icf)*d1(irf) ;
diff --git a/matlab/check_list_of_variables.m b/matlab/check_list_of_variables.m
index 8fabffe54bd1c4b61b0831699d5640fa7d45f5c6..f13182c855f9290d68b0e04e9b11cd488427be38 100644
--- a/matlab/check_list_of_variables.m
+++ b/matlab/check_list_of_variables.m
@@ -32,7 +32,7 @@ function varlist = check_list_of_variables(options_, M_, varlist)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 % Get uniques
-[junk1, junk2, index_uniques] = varlist_indices(varlist, M_.endo_names);
+[~, ~, index_uniques] = varlist_indices(varlist, M_.endo_names);
 varlist = varlist(index_uniques);
 
 msg = false;
diff --git a/matlab/check_posterior_sampler_options.m b/matlab/check_posterior_sampler_options.m
index 4683639f3af1418b084e16d42ad58e0f3645093c..0cb50758672fae4ec22f02b9dd6a115727ba4cea 100644
--- a/matlab/check_posterior_sampler_options.m
+++ b/matlab/check_posterior_sampler_options.m
@@ -387,7 +387,7 @@ if ~strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
 end
 
 if options_.load_mh_file && posterior_sampler_options.use_mh_covariance_matrix
-    [junk, invhess] = compute_mh_covariance_matrix;
+    [~, invhess] = compute_mh_covariance_matrix;
     posterior_sampler_options.invhess = invhess;
 end
 
@@ -409,7 +409,7 @@ if strcmp(posterior_sampler_options.posterior_sampling_method,'slice')
                 error('check_posterior_sampler_options:: This error should not occur, please contact developers.')
             end
             % % %             if options_.load_mh_file && options_.use_mh_covariance_matrix,
-            % % %                 [junk, invhess] = compute_mh_covariance_matrix;
+            % % %                 [~, invhess] = compute_mh_covariance_matrix;
             % % %                 posterior_sampler_options.invhess = invhess;
             % % %             end
             [V1, D]=eig(invhess);
diff --git a/matlab/discretionary_policy_1.m b/matlab/discretionary_policy_1.m
index f154912d4e874babd2584662d307bff1cc19ae74..91586970b43cd88f119d139c8549c285ed8ec20d 100644
--- a/matlab/discretionary_policy_1.m
+++ b/matlab/discretionary_policy_1.m
@@ -63,7 +63,7 @@ end
 %call steady_state_file if present to update parameters
 if options_.steadystate_flag
     % explicit steady state file
-    [junk,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
+    [~,M_.params,info] = evaluate_steady_state_file(oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state],M_, ...
                                                       options_,0);
 end
 [U,Uy,W] = feval([M_.fname,'.objective.static'],zeros(endo_nbr,1),[], M_.params);
@@ -129,7 +129,7 @@ iter=1;
 for j=1:numel(Indices)
     eval(['A',Indices{j},'=zeros(eq_nbr,endo_nbr);'])
     if strcmp(Indices{j},'0')||(strcmp(Indices{j},'lag') && MaxLag)||(strcmp(Indices{j},'lead') && MaxLead)
-        [junk,row,col]=find(lead_lag_incidence(iter,:));
+        [~,row,col]=find(lead_lag_incidence(iter,:));
         eval(['A',Indices{j},'(:,row)=jacobia_(:,col);'])
         iter=iter+1;
     end
diff --git a/matlab/dr_block.m b/matlab/dr_block.m
index 0b4d676ee7f9c0aa8a832cb008027b0920e5d896..c0209d527fd892a567cdceeec8b765729cd4ab0f 100644
--- a/matlab/dr_block.m
+++ b/matlab/dr_block.m
@@ -409,7 +409,7 @@ for i = 1:Size
         index_c = lead_lag_incidence(2,:);             % Index of all endogenous variables present at time=t
         index_s = lead_lag_incidence(2,1:n_static);    % Index of all static endogenous variables present at time=t
         if n_static > 0
-            [Q, junk] = qr(jacob(:,index_s));
+            [Q, ~] = qr(jacob(:,index_s));
             aa = Q'*jacob;
         else
             aa = jacob;
@@ -476,7 +476,7 @@ for i = 1:Size
                     if isfield(options_,'indeterminacy_continuity')
                         if options_.indeterminacy_msv == 1
                             [ss,tt,w,q] = qz(E',D');
-                            [ss,tt,w,junk] = reorder(ss,tt,w,q);
+                            [ss,tt,w,~] = reorder(ss,tt,w,q);
                             ss = ss';
                             tt = tt';
                             w  = w';
diff --git a/matlab/draw_prior_density.m b/matlab/draw_prior_density.m
index 8e9ff93c6b782939d0080c99c8acf5921c931e68..b5d993e85427d33ea90432b7f223fffd9c42d2ea 100644
--- a/matlab/draw_prior_density.m
+++ b/matlab/draw_prior_density.m
@@ -111,7 +111,7 @@ switch pshape(indx)
 end
 
 if pshape(indx) ~= 5
-    [junk,k1] = max(dens);
+    [~,k1] = max(dens);
     if k1 == 1 || k1 == length(dens)
         k = find(dens > 10);
         dens(k) = NaN;
diff --git a/matlab/dyn_first_order_solver.m b/matlab/dyn_first_order_solver.m
index 6981971673ef91b54e0b88c47472e7d27e12174a..c7f97e9b5b91bbf4a6e2de8bbf9cd201e222ebe7 100644
--- a/matlab/dyn_first_order_solver.m
+++ b/matlab/dyn_first_order_solver.m
@@ -124,7 +124,7 @@ if isempty(reorder_jacobian_columns)
                                                       nsfwrd)))];
     index_e2 = npred+nboth+(1:nboth);
 
-    [junk,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var));
+    [~,cols_b] = find(lead_lag_incidence(maximum_lag+1, order_var));
 
     reorder_jacobian_columns = [nonzeros(lead_lag_incidence(:,order_var)'); ...
                         nz+(1:exo_nbr)'];
@@ -138,7 +138,7 @@ dr.state_var = state_var;
 jacobia = jacobia(:,reorder_jacobian_columns);
 
 if nstatic > 0
-    [Q, junk] = qr(jacobia(:,index_s));
+    [Q, ~] = qr(jacobia(:,index_s));
     aa = Q'*jacobia;
 else
     aa = jacobia;
diff --git a/matlab/dyn_ramsey_static.m b/matlab/dyn_ramsey_static.m
index cf171e847adff4e1134c18454303016065710486..ccbad5e7bc57108297f292e5d7bd14d8ca65c7ad 100644
--- a/matlab/dyn_ramsey_static.m
+++ b/matlab/dyn_ramsey_static.m
@@ -75,7 +75,7 @@ elseif options_.steadystate_flag
     ys_init(k_inst) = inst_val;
     exo_ss = [oo.exo_steady_state oo.exo_det_steady_state];
     [xx,params] = evaluate_steady_state_file(ys_init,exo_ss,M,options_,~options_.steadystate.nocheck); %run steady state file again to update parameters
-    [junk,junk,steady_state] = nl_func(inst_val); %compute and return steady state
+    [~,~,steady_state] = nl_func(inst_val); %compute and return steady state
 else
     n_var = M.orig_endo_nbr;
     xx = oo.steady_state(1:n_var);
@@ -85,7 +85,7 @@ else
     if info1~=0
         check=81;
     end
-    [junk,junk,steady_state] = nl_func(xx);
+    [~,~,steady_state] = nl_func(xx);
 end
 
 
@@ -194,8 +194,8 @@ end
 function result = check_static_model(ys,M,options_,oo)
 result = false;
 if (options_.bytecode)
-    [chck, res, junk] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
-                                 M.params, 'evaluate');
+    [chck, res, ~] = bytecode('static',ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
+                              M.params, 'evaluate');
 else
     res = feval([M.fname '.static'],ys,[oo.exo_steady_state oo.exo_det_steady_state], ...
                 M.params);
diff --git a/matlab/dyn_risky_steadystate_solver.m b/matlab/dyn_risky_steadystate_solver.m
index a17e213261c149ac0ab38b1d68623346bd5b75ed..04c50b84b234287a994130c8e792906f8119f810 100644
--- a/matlab/dyn_risky_steadystate_solver.m
+++ b/matlab/dyn_risky_steadystate_solver.m
@@ -88,7 +88,7 @@ exo_nbr = M.exo_nbr;
 
 M.var_order_endo_names = M.endo_names(dr.order_var);
 
-[junk,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var));
+[~,dr.i_fwrd_g,i_fwrd_f] = find(lead_lag_incidence(3,order_var));
 dr.i_fwrd_f = i_fwrd_f;
 nd = nnz(lead_lag_incidence) + M.exo_nbr;
 dr.nd = nd;
diff --git a/matlab/dyn_second_order_solver.m b/matlab/dyn_second_order_solver.m
index df6ba76939e7217aa97a9dab88ed4dcad48e839e..5040d14933c6ff8bbd335189767e62bd06fd43dc 100644
--- a/matlab/dyn_second_order_solver.m
+++ b/matlab/dyn_second_order_solver.m
@@ -105,7 +105,7 @@ k1 = find(kstate(:,2) == M_.maximum_endo_lag+2);
 % Jacobian with respect to the variables with the highest lead
 fyp = jacobia(:,kstate(k1,3)+nnz(M_.lead_lag_incidence(M_.maximum_endo_lag+1,:)));
 B(:,nstatic+M_.npred+1:end) = fyp;
-[junk,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var));
+[~,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+M_.maximum_endo_lead+1,order_var));
 A(1:M_.endo_nbr,nstatic+1:nstatic+nspred)=...
     A(1:M_.endo_nbr,nstatic+[1:nspred])+fyp*gx1(k1,1:nspred);
 C = Gy;
@@ -162,7 +162,7 @@ kp = sum(kstate(:,2) <= M_.maximum_endo_lag+1);
 E1 = [eye(nspred); zeros(kp-nspred,nspred)];
 H = E1;
 hxx = dr.ghxx(nstatic+[1:nspred],:);
-[junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
+[~,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+2,order_var));
 k3 = nnz(M_.lead_lag_incidence(1:M_.maximum_endo_lag+1,:))+(1:M_.nsfwrd)';
 [B1, err] = sparse_hessian_times_B_kronecker_C(hessian_mat(:,kh(k3,k3)),gu(k2a,:),threads_BC);
 mexErrCheck('sparse_hessian_times_B_kronecker_C', err);
diff --git a/matlab/dynare.m b/matlab/dynare.m
index fa38088034ad18c854ceac8677d451e0f47b7220..00f18c37725237027c5d26ba4a565eabe033f99b 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -191,7 +191,7 @@ end
 if ispc
     arch = getenv('PROCESSOR_ARCHITECTURE');
 else
-    [junk, arch] = system('uname -m');
+    [~, arch] = system('uname -m');
 end
 
 if isempty(strfind(arch, '64'))
diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m
index a0eb52924b210df5d63c48acbc458d8d9affa865..776adbaa05953f0347b303870037faf004daed67 100644
--- a/matlab/dynare_estimation_1.m
+++ b/matlab/dynare_estimation_1.m
@@ -235,8 +235,8 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
             if options_.analytic_derivation && strcmp(func2str(objective_function),'dsge_likelihood')
                 ana_deriv_old = options_.analytic_derivation;
                 options_.analytic_derivation = 2;
-                [junk1, junk2,junk3, junk4, hh] = feval(objective_function,xparam1, ...
-                                                        dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
+                [~,~,~,~,hh] = feval(objective_function,xparam1, ...
+                                     dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
                 options_.analytic_derivation = ana_deriv_old;
             elseif ~isnumeric(options_.mode_compute) || ~(isequal(options_.mode_compute,5) && newratflag~=1 && strcmp(func2str(objective_function),'dsge_likelihood'))
                 % with flag==0, we force to use the hessian from outer product gradient of optimizer 5
@@ -373,9 +373,8 @@ if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
         skipline()
     end
     if options_.dsge_var
-        [junk1,junk2,junk3,junk4,junk5,junk6,junk7,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =...
+        [~,~,~,~,~,~,~,oo_.dsge_var.posterior_mode.PHI_tilde,oo_.dsge_var.posterior_mode.SIGMA_u_tilde,oo_.dsge_var.posterior_mode.iXX,oo_.dsge_var.posterior_mode.prior] =...
             feval(objective_function,xparam1,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);
-        clear('junk1','junk2','junk3','junk4','junk5','junk6','junk7');
     end
 
 elseif ~any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation
@@ -519,7 +518,7 @@ if (any(bayestopt_.pshape  >0 ) && options_.mh_replic) || ...
                 oo_.posterior.metropolis=oo_load_mh.oo_.posterior.metropolis;
             end
         end
-        [error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_);
+        [error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_);
         if options_.bayesian_irf
             if error_flag
                 error('Estimation::mcmc: I cannot compute the posterior IRFs!')
diff --git a/matlab/dynare_estimation_init.m b/matlab/dynare_estimation_init.m
index fb457520971337eb03564cd6d4eccbdb3e0e87d0..7676c644575736644517fca349c0ba9fbe794e5b 100644
--- a/matlab/dynare_estimation_init.m
+++ b/matlab/dynare_estimation_init.m
@@ -454,38 +454,38 @@ if options_.block == 1
     % Set restrict_state to postion of observed + state variables in expanded state vector.
     oo_.dr.restrict_var_list  = [k1(i_posA) M_.state_var(sort(i_posB))];
     % set mf0 to positions of state variables in restricted state vector for likelihood computation.
-    [junk,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list);
+    [~,bayestopt_.mf0] = ismember(M_.state_var',oo_.dr.restrict_var_list);
     % Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
-    [junk,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list);
+    [~,bayestopt_.mf1] = ismember(k1,oo_.dr.restrict_var_list);
     % Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
     bayestopt_.mf2  = var_obs_index_dr;
     bayestopt_.mfys = k1;
     oo_.dr.restrict_columns = [size(i_posA,1)+(1:size(M_.state_var,2))];
     [k2, i_posA, i_posB] = union(k3p, M_.state_var', 'rows');
     bayestopt_.smoother_var_list = [k3p(i_posA); M_.state_var(sort(i_posB))'];
-    [junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:));
-    [junk,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var);
+    [~,~,bayestopt_.smoother_saved_var_list] = intersect(k3p,bayestopt_.smoother_var_list(:));
+    [~,ic] = intersect(bayestopt_.smoother_var_list,M_.state_var);
     bayestopt_.smoother_restrict_columns = ic;
-    [junk,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list);
+    [~,bayestopt_.smoother_mf] = ismember(k1, bayestopt_.smoother_var_list);
 else
     % Define union of observed and state variables
     k2 = union(var_obs_index_dr,[M_.nstatic+1:M_.nstatic+M_.nspred]', 'rows');
     % Set restrict_state to postion of observed + state variables in expanded state vector.
     oo_.dr.restrict_var_list = k2;
     % set mf0 to positions of state variables in restricted state vector for likelihood computation.
-    [junk,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
+    [~,bayestopt_.mf0] = ismember([M_.nstatic+1:M_.nstatic+M_.nspred]',k2);
     % Set mf1 to positions of observed variables in restricted state vector for likelihood computation.
-    [junk,bayestopt_.mf1] = ismember(var_obs_index_dr,k2);
+    [~,bayestopt_.mf1] = ismember(var_obs_index_dr,k2);
     % Set mf2 to positions of observed variables in expanded state vector for filtering and smoothing.
     bayestopt_.mf2  = var_obs_index_dr;
     bayestopt_.mfys = k1;
-    [junk,ic] = intersect(k2,nstatic+(1:npred)');
+    [~,ic] = intersect(k2,nstatic+(1:npred)');
     oo_.dr.restrict_columns = [ic; length(k2)+(1:nspred-npred)'];
     bayestopt_.smoother_var_list = union(k2,k3);
-    [junk,junk,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:));
-    [junk,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)');
+    [~,~,bayestopt_.smoother_saved_var_list] = intersect(k3,bayestopt_.smoother_var_list(:));
+    [~,ic] = intersect(bayestopt_.smoother_var_list,nstatic+(1:npred)');
     bayestopt_.smoother_restrict_columns = ic;
-    [junk,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list);
+    [~,bayestopt_.smoother_mf] = ismember(var_obs_index_dr, bayestopt_.smoother_var_list);
 end
 
 if options_.analytic_derivation
diff --git a/matlab/dynare_gradient.m b/matlab/dynare_gradient.m
index 2f4dfc9d499623d5a4ef250d4bc7dad0adb7a868..71e9da33e7141129cd2f6f1717344d2d564668f1 100644
--- a/matlab/dynare_gradient.m
+++ b/matlab/dynare_gradient.m
@@ -52,11 +52,11 @@ for i=1:m
     else
         h = H(:,i);
     end
-    [Fh,junk1,junk2,flag] = feval(fcn, x+transpose(h), varargin{:});
+    [Fh,~,~,flag] = feval(fcn, x+transpose(h), varargin{:});
     if flag
         G(:,i) = (Fh-F)/epsilon;
     else
-        [Fh,junk1,junk2,flag] = feval(fcn, x-transpose(h), varargin{:});
+        [Fh,~,~,flag] = feval(fcn, x-transpose(h), varargin{:});
         if flag
             G(:,i) = (F-Fh)/epsilon;
         else
diff --git a/matlab/evaluate_steady_state.m b/matlab/evaluate_steady_state.m
index 993148fc1f8ca0ad50fdb074228fd53b0dc30fb7..9293d53acc052d2ef1ef2f18792083329b566783 100644
--- a/matlab/evaluate_steady_state.m
+++ b/matlab/evaluate_steady_state.m
@@ -307,7 +307,7 @@ if M.static_and_dynamic_models_differ
     z = repmat(ys,1,M.maximum_lead + M.maximum_lag + 1);
     zx = repmat([exo_ss'], M.maximum_lead + M.maximum_lag + 1, 1);
     if options.bytecode
-        [chck, r, junk]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1);
+        [chck, r, ~]= bytecode('dynamic','evaluate', z, zx, M.params, ys, 1);
         mexErrCheck('bytecode', chck);
     elseif options.block
         [r, oo.dr] = feval([M.fname '.dynamic'], z', zx, M.params, ys, M.maximum_lag+1, oo.dr);
diff --git a/matlab/execute_prior_posterior_function.m b/matlab/execute_prior_posterior_function.m
index cb7884e83916c945a4c19fb069f3f130204c5ec1..e998dd19b001da35cc7e16d89372aa18c0823da4 100644
--- a/matlab/execute_prior_posterior_function.m
+++ b/matlab/execute_prior_posterior_function.m
@@ -55,7 +55,7 @@ if strcmpi(type,'posterior')
     CutSample(M_, options_, estim_params_);
     %% initialize metropolis draws
     options_.sub_draws=n_draws; %set draws for sampling; changed value is not returned to base workspace
-    [error_flag,junk,options_]= metropolis_draw(1,options_,estim_params_,M_);
+    [error_flag,~,options_]= metropolis_draw(1,options_,estim_params_,M_);
     if error_flag
         error('EXECUTE_POSTERIOR_FUNCTION: The draws could not be initialized')
     end
diff --git a/matlab/getH.m b/matlab/getH.m
index a7de28bc0893bf77a7e2add2578301c729963614..efd53d9d6b98adf389a991549d6d90dac8e3d90e 100644
--- a/matlab/getH.m
+++ b/matlab/getH.m
@@ -319,8 +319,8 @@ if nargout > 5
     end
 end
 
-[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
-                                                  oo_.dr.order_var));
+[~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
+                                               oo_.dr.order_var));
 GAM0 = zeros(M_.endo_nbr,M_.endo_nbr);
 Dg0 = zeros(M_.endo_nbr,M_.endo_nbr,param_nbr);
 GAM0(:,cols_b) = g1(:,cols_j);
diff --git a/matlab/get_name_of_the_last_mh_file.m b/matlab/get_name_of_the_last_mh_file.m
index e6732a2ef4ca62647ddda2cd1cb76f7fce982dbd..2741f7b52fdf3daf860767e4b56ee35fb9000533 100644
--- a/matlab/get_name_of_the_last_mh_file.m
+++ b/matlab/get_name_of_the_last_mh_file.m
@@ -43,7 +43,7 @@ bk_number = record.Nblck ;
 predicted_mhname = [ BaseName '_mh' int2str(mh_number) '_blck' int2str(bk_number) '.mat' ] ;
 
 all_mh_files = dir([BaseName '_mh*_blck*' ]);
-[junk,idx] = sort([all_mh_files.datenum]);
+[~,idx] = sort([all_mh_files.datenum]);
 mhname = all_mh_files(idx(end)).name;
 
 if ~strcmpi(mhname,predicted_mhname)
diff --git a/matlab/global_initialization.m b/matlab/global_initialization.m
index 6a1acadc989ec25b802351e768ce5faadffd944d..93c1e8ad6bb38716744f88a0086cec22a130be15 100644
--- a/matlab/global_initialization.m
+++ b/matlab/global_initialization.m
@@ -130,8 +130,8 @@ set_dynare_seed('default');
 
 
 % Create directories
-[junk,junk]=mkdir(M_.fname);
-[junk,junk]=mkdir([M_.fname filesep 'Output']);
+[~,~]=mkdir(M_.fname);
+[~,~]=mkdir([M_.fname filesep 'Output']);
 
 % Load user configuration file.
 if isfield(options_, 'global_init_file')
diff --git a/matlab/graph_decomp.m b/matlab/graph_decomp.m
index 7b150a5da03b081880c4c297ca5e9af1a7828b47..eda542009c4d280aa620e3c8f5d911ee52980aa7 100644
--- a/matlab/graph_decomp.m
+++ b/matlab/graph_decomp.m
@@ -108,7 +108,7 @@ comp_nbr0=comp_nbr;
 for j=1:nvar
     z1 = squeeze(z(i_var(j),:,:));
     if screen_shocks
-        [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
+        [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
         labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
         zres = sum(z1(isort(17:end),:),1);
         z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
diff --git a/matlab/graph_decomp_detail.m b/matlab/graph_decomp_detail.m
index 2605dbac3e3eb93494a276ac40b8811317231997..9b920770ba9db4f9fe56a5657f0ed3cc7248fc22 100644
--- a/matlab/graph_decomp_detail.m
+++ b/matlab/graph_decomp_detail.m
@@ -135,7 +135,7 @@ comp_nbr0=comp_nbr;
 for j=1:nvar
     z1 = squeeze(z(i_var(j),:,:));
     if screen_shocks,
-        [junk, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
+        [~, isort] = sort(mean(abs(z1(1:end-2,:)')), 'descend');
         labels = char(char(shock_names(isort(1:16))),'Others', 'Initial values');
         zres = sum(z1(isort(17:end),:),1);
         z1 = [z1(isort(1:16),:); zres; z1(comp_nbr0:end,:)];
diff --git a/matlab/gsa/prior_draw_gsa.m b/matlab/gsa/prior_draw_gsa.m
index c3c92d40d402d2ef2cf404f6569863ab6091cf4f..d772ae22a88a6ade4b631df1eed5c487883496cf 100644
--- a/matlab/gsa/prior_draw_gsa.m
+++ b/matlab/gsa/prior_draw_gsa.m
@@ -49,7 +49,7 @@ if init
     pdraw = zeros(npar,1);
     lbcum = zeros(npar,1);
     ubcum = ones(npar,1);
-    [junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds
+    [~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
     if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
         % Set prior bounds
         bounds = prior_bounds(bayestopt_, options_.prior_trunc);
diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m
index f4f73188c7cd70ff10af777fe8c84f2a716eb206..15c6f22a5ca21b439979bfc187ffd5be805cf1ea 100644
--- a/matlab/gsa/stab_map_.m
+++ b/matlab/gsa/stab_map_.m
@@ -92,7 +92,7 @@ p2 = bayestopt_.p2(nshock+1:end);
 p3 = bayestopt_.p3(nshock+1:end);
 p4 = bayestopt_.p4(nshock+1:end);
 
-[junk1,junk2,junk3,lb,ub,junk4] = set_prior(estim_params_,M_,options_); %Prepare bounds
+[~,~,~,lb,ub,~] = set_prior(estim_params_,M_,options_); %Prepare bounds
 if ~isempty(bayestopt_) && any(bayestopt_.pshape > 0)
     % Set prior bounds
     bounds = prior_bounds(bayestopt_, options_.prior_trunc);
diff --git a/matlab/identification_analysis.m b/matlab/identification_analysis.m
index bc4d8ad86da4e93b624f9e1c7d6af929c2a2b6b6..69b10efadd76d89d7062fd1b87da409ec051fe90 100644
--- a/matlab/identification_analysis.m
+++ b/matlab/identification_analysis.m
@@ -198,7 +198,7 @@ if info(1)==0
             if isoctave || matlab_ver_less_than('8.3')
                 [V,D]=eig(cc);
                 %fix for older Matlab versions that do not support computing left eigenvalues, see http://mathworks.com/help/releases/R2012b/matlab/ref/eig.html
-                [W,junk] = eig(cc.');
+                [W,~] = eig(cc.');
                 W = conj(W);
             else
                 [V,D,W]=eig(cc);
diff --git a/matlab/initial_condition_decomposition.m b/matlab/initial_condition_decomposition.m
index 52e468a9f116758f68124d0e5604bc5c4783cad2..0c846b1ff50493fcd5c5e0912ebe10fa660b341b 100644
--- a/matlab/initial_condition_decomposition.m
+++ b/matlab/initial_condition_decomposition.m
@@ -74,7 +74,7 @@ end
 if ~isfield(oo_,'initval_decomposition')
     options_.selected_variables_only = 0; %make sure all variables are stored
     options_.plot_priors=0;
-    [oo,M,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
+    [oo,M,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
 
     % reduced form
     dr = oo.dr;
diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m
index bc7d9fb20ea29e003e4e253a04401b254cd439ef..05972ef30a52750731fe944f5be270eb8ef2a085 100644
--- a/matlab/initial_estimation_checks.m
+++ b/matlab/initial_estimation_checks.m
@@ -66,7 +66,7 @@ if isfield(EstimatedParameters,'param_vals') && ~isempty(EstimatedParameters.par
     %check whether steady state file changes estimated parameters
     Model_par_varied=Model; %store Model structure
     Model_par_varied.params(EstimatedParameters.param_vals(:,1))=Model_par_varied.params(EstimatedParameters.param_vals(:,1))*1.01; %vary parameters
-    [junk, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0);
+    [~, new_steady_params_2] = evaluate_steady_state(DynareResults.steady_state,Model_par_varied,DynareOptions,DynareResults,DynareOptions.diffuse_filter==0);
 
     changed_par_indices=find((old_steady_params(EstimatedParameters.param_vals(:,1))-new_steady_params(EstimatedParameters.param_vals(:,1))) ...
                              | (Model_par_varied.params(EstimatedParameters.param_vals(:,1))-new_steady_params_2(EstimatedParameters.param_vals(:,1))));
@@ -105,7 +105,7 @@ end
 % display warning if some parameters are still NaN
 test_for_deep_parameters_calibration(Model);
 
-[lnprior, junk1,junk2,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
+[lnprior,~,~,info]= priordens(xparam1,BayesInfo.pshape,BayesInfo.p6,BayesInfo.p7,BayesInfo.p3,BayesInfo.p4);
 if info
     fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',BayesInfo.name{info,1})
     error('The initial value of the prior is -Inf')
diff --git a/matlab/kalman/likelihood/kalman_filter_ss.m b/matlab/kalman/likelihood/kalman_filter_ss.m
index 5510de9f36b9d262f470551878c6742b9e1e71fe..d8dc80468350f7ddb2c4a74550938c7d4405375d 100644
--- a/matlab/kalman/likelihood/kalman_filter_ss.m
+++ b/matlab/kalman/likelihood/kalman_filter_ss.m
@@ -114,9 +114,9 @@ while t <= last
     tmp = (a+K*v);
     if analytic_derivation
         if analytic_derivation==2
-            [Da,junk,DLIKt,D2a,junk2, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]);
+            [Da,~,DLIKt,D2a,~, Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady,D2a,D2Yss,D2T,[],[]);
         else
-            [Da,junk,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady);
+            [Da,~,DLIKt,Hesst] = computeDLIK(k,tmp,Z,Zflag,v,T,K,[],iF,Da,DYss,DT,[],[],[],notsteady);
         end
         DLIK = DLIK + DLIKt;
         if analytic_derivation==2 || asy_hess
diff --git a/matlab/kalman/likelihood/univariate_kalman_filter_ss.m b/matlab/kalman/likelihood/univariate_kalman_filter_ss.m
index 9d8cbff06fa912f12c69768b34c2f2338ff33c7a..e67a87f18b4c6360e6ce077722f2cb00d04ecf11 100644
--- a/matlab/kalman/likelihood/univariate_kalman_filter_ss.m
+++ b/matlab/kalman/likelihood/univariate_kalman_filter_ss.m
@@ -153,7 +153,7 @@ while t<=last
     end
     if analytic_derivation
         if analytic_derivation==2
-            [Da,junk,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T);
+            [Da,~,D2a] = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0,D2a,D2P,D2T);
         else
             Da = univariate_computeDstate(k,a,P,T,Da,DP,DT,[],0);
         end
diff --git a/matlab/lmmcp/lmmcp.m b/matlab/lmmcp/lmmcp.m
index 50404ac7c948145c941dd7e07881f49e9d8127cb..e5911a4748186dcc60c4b31c15b34160d19d3b1e 100644
--- a/matlab/lmmcp/lmmcp.m
+++ b/matlab/lmmcp/lmmcp.m
@@ -392,7 +392,7 @@ while (k < kmax) && (Psix > eps2)
     Fx        = Fxnew;
     Phix      = Phixnew;
     Psix      = Psixnew;
-    [junk,DFx]   = feval(FUN,x,varargin{:});
+    [~,DFx]   = feval(FUN,x,varargin{:});
     DPhix     = DPhi(x,Fx,DFx,lb,ub,lambda1,lambda2,n,Indexset);
     DPsix     = DPhix'*Phix;
     normDPsix = norm(DPsix);
diff --git a/matlab/load_m_file_data_legacy.m b/matlab/load_m_file_data_legacy.m
index a78563796ba4e05be90e12796725cfdaa61dc4c9..2709fe503290746eb19b1887929ff0b568511171 100644
--- a/matlab/load_m_file_data_legacy.m
+++ b/matlab/load_m_file_data_legacy.m
@@ -18,7 +18,7 @@ function o2WysrOISH  = load_m_file_data_legacy(datafile, U7ORsJ0vy3) % --*-- Uni
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 cXDHdrXnqo5KwwVpTRuc6OprAW = datafile(1:end-2);
-[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,junk] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
+[pathtocXDHdrXnqo5KwwVpTRuc6OprAW,cXDHdrXnqo5KwwVpTRuc6OprAW,~] = fileparts(cXDHdrXnqo5KwwVpTRuc6OprAW);
 
 if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
     % We need to change directory, first we keep the current directory in memory...
@@ -38,7 +38,7 @@ if ~isempty(pathtocXDHdrXnqo5KwwVpTRuc6OprAW)
 end
 
 % Clear all the variables except the ones defined in the script.
-clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW', 'junk');
+clear('pathtocXDHdrXnqo5KwwVpTRuc6OprAW', 'cXDHdrXnqo5KwwVpTRuc6OprAW');
 
 % Get the list of variables in the script.
 mj6F4eU1BN = whos();
diff --git a/matlab/model_diagnostics.m b/matlab/model_diagnostics.m
index e8f5ff81c7c92a8f4a6d43a856586f56aedc792c..5696f772693ab9031acbd7d34c310cf85f69846f 100644
--- a/matlab/model_diagnostics.m
+++ b/matlab/model_diagnostics.m
@@ -204,22 +204,22 @@ z = repmat(dr.ys,1,klen);
 if ~options.block
     if options.order == 1
         if (options.bytecode)
-            [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
-                                            M.params, dr.ys, 1);
+            [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
+                                         M.params, dr.ys, 1);
             jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
         else
-            [junk,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ...
-                                    M.params, dr.ys, it_);
+            [~,jacobia_] = feval([M.fname '.dynamic'],z(iyr0),exo_simul, ...
+                                 M.params, dr.ys, it_);
         end
     elseif options.order >= 2
         if (options.bytecode)
-            [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
-                                            M.params, dr.ys, 1);
+            [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
+                                         M.params, dr.ys, 1);
             jacobia_ = [loc_dr.g1 loc_dr.g1_x];
         else
-            [junk,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),...
-                                             exo_simul, ...
-                                             M.params, dr.ys, it_);
+            [~,jacobia_,hessian1] = feval([M.fname '.dynamic'],z(iyr0),...
+                                          exo_simul, ...
+                                          M.params, dr.ys, it_);
         end
         if options.use_dll
             % In USE_DLL mode, the hessian is in the 3-column sparse representation
diff --git a/matlab/occbin/get_coef.m b/matlab/occbin/get_coef.m
index f2dbde5a619dce0a95c22c304f09b4ab80258019..924be1b1c7dc19615cdb1f337cb6514322db7138 100644
--- a/matlab/occbin/get_coef.m
+++ b/matlab/occbin/get_coef.m
@@ -6,19 +6,19 @@ coef_y = zeros(endo_nbr,3*endo_nbr);
 coef_u = zeros(endo_nbr,M.exo_nbr);
 
 if M.maximum_lag > 0
-    [junk,c1,c2] = find(ll(1,:));
+    [~,c1,c2] = find(ll(1,:));
     coef_y(:,c1) = jacobian(:,c2);
-    [junk,c1,c2] = find(ll(2,:));
+    [~,c1,c2] = find(ll(2,:));
     coef_y(:,c1+endo_nbr) = jacobian(:,c2);
     if M.maximum_lead > 0
-            [junk,c1,c2] = find(ll(3,:));
+            [~,c1,c2] = find(ll(3,:));
             coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
     end
 else
-    [junk,c1,c2] = find(ll(1,:));
+    [~,c1,c2] = find(ll(1,:));
     coef_y(:,c1+endo_nbr) = jacobian(:,c2);
     if M.maximum_lead > 0
-            [junk,c1,c2] = find(ll(2,:));
+            [~,c1,c2] = find(ll(2,:));
             coef_y(:,c1+2*endo_nbr) = jacobian(:,c2);
     end
 end
diff --git a/matlab/optimization/csminwel1.m b/matlab/optimization/csminwel1.m
index cfa8699322bfb2d3fff98f4914f1ab86f9184f73..902806596d0beb0e89f09d053c29db686fc7a456 100644
--- a/matlab/optimization/csminwel1.m
+++ b/matlab/optimization/csminwel1.m
@@ -142,7 +142,7 @@ while ~done
             elseif ischar(grad)
                 [g1, badg1] = grad(x1,varargin{:});
             else
-                [junk1,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:});
+                [~,cost_flag,g1] = penalty_objective_function(x1,fcn,penalty,varargin{:});
                 badg1 = ~cost_flag;
             end
             wall1=badg1;
@@ -169,7 +169,7 @@ while ~done
                     elseif ischar(grad)
                         [g2, badg2] = grad(x2,varargin{:});
                     else
-                        [junk2,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:});
+                        [~,cost_flag,g2] = penalty_objective_function(x1,fcn,penalty,varargin{:});
                         badg2 = ~cost_flag;
                     end
                     wall2=badg2;
@@ -201,7 +201,7 @@ while ~done
                             elseif ischar(grad)
                                 [g3, badg3] = grad(x3,varargin{:});
                             else
-                                [junk3,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:});
+                                [~,cost_flag,g3] = penalty_objective_function(x1,fcn,penalty,varargin{:});
                                 badg3 = ~cost_flag;
                             end
                             wall3=badg3;
@@ -261,7 +261,7 @@ while ~done
             elseif ischar(grad)
                 [gh, badgh] = grad(xh,varargin{:});
             else
-                [junkh,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:});
+                [~,cost_flag,gh] = penalty_objective_function(x1,fcn,penalty,varargin{:});
                 badgh = ~cost_flag;
             end
         end
diff --git a/matlab/optimization/numgrad3_.m b/matlab/optimization/numgrad3_.m
index 6358138335d3170af2d72e77e9b3332579e15021..a59fa6ae6bfea0b0296e6efff44955d42c5e9379 100644
--- a/matlab/optimization/numgrad3_.m
+++ b/matlab/optimization/numgrad3_.m
@@ -46,12 +46,12 @@ for i=1:n
     xiold = x(i);
     h = step_length_correction(xiold,scale,i)*delta;
     x(i) = xiold + h;
-    [f1,junk1,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:});
+    [f1,~,cost_flag1] = penalty_objective_function(x, fcn, penalty, varargin{:});
     if ~cost_flag1
         fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the right!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
     end
     x(i) = xiold - h;
-    [f2,junk2,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
+    [f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
     if ~cost_flag2
         fprintf('Gradient w.r.t. parameter number %3d (x=%16.8f,+h=%16.8f,f0=%16.8f,f1=%16.8f,f2=%16.8f,g0=%16.8f): penalty on the left!\n',i,xiold,h,f0,f1,f2,(f1 - f2) / (2*h))
     end
diff --git a/matlab/optimization/numgrad5_.m b/matlab/optimization/numgrad5_.m
index bbce6fd0efce3d17ec094be7e49e4ed63ef13b25..9fbdc9b8e4b7fde6b0a7109e206f4f6f8012ad43 100644
--- a/matlab/optimization/numgrad5_.m
+++ b/matlab/optimization/numgrad5_.m
@@ -48,13 +48,13 @@ for i=1:n
     xiold = x(i);
     h = step_length_correction(xiold,scale,i)*delta;
     x(i) = xiold+h;
-    [f1,junk1,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:});
+    [f1,~,cost_flag1,] = penalty_objective_function(x, fcn, penalty, varargin{:});
     x(i) = xiold-h;
-    [f2,junk1,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
+    [f2,~,cost_flag2] = penalty_objective_function(x, fcn, penalty, varargin{:});
     x(i) = xiold+2*h;
-    [f3,junk1,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:});
+    [f3,~,cost_flag3] = penalty_objective_function(x, fcn, penalty, varargin{:});
     x(i) = xiold-2*h;
-    [f4,junk1,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:});
+    [f4,~,cost_flag4] = penalty_objective_function(x, fcn, penalty, varargin{:});
     if f0<f1 && f1<f3 && f0<f2 && f2<f4
         g0 = 0;
     else
diff --git a/matlab/optimization/simplex_optimization_routine.m b/matlab/optimization/simplex_optimization_routine.m
index ab0d181e7e7c441153a3e2d33f7d3072ae09ad63..af11953f609b79adcbd4e81e29c8a92787860a8f 100644
--- a/matlab/optimization/simplex_optimization_routine.m
+++ b/matlab/optimization/simplex_optimization_routine.m
@@ -190,7 +190,7 @@ if verbose
     disp('Simplex initialization...')
 end
 initial_point = x;
-[initial_score,junk1,nopenalty] = feval(objective_function,x,varargin{:});
+[initial_score,~,nopenalty] = feval(objective_function,x,varargin{:});
 if ~nopenalty
     disp('Cannot initialize the simplex with the provided initial guess.')
     skipline()
@@ -528,7 +528,7 @@ for j = 1:n
     end
     v(:,j+1) = y;
     x = y;
-    [fv(j+1),junk1,nopenalty_flag] = feval(objective_function,x,varargin{:});
+    [fv(j+1),~,nopenalty_flag] = feval(objective_function,x,varargin{:});
     if check_delta
         while ~nopenalty_flag
             if y(j)~=0
@@ -544,7 +544,7 @@ for j = 1:n
             end
             v(:,j+1) = y;
             x = y;
-            [fv(j+1),junk1,nopenalty_flag] = feval(objective_function,x,varargin{:});
+            [fv(j+1),~,nopenalty_flag] = feval(objective_function,x,varargin{:});
         end
     end
 end
diff --git a/matlab/partial_information/dr1_PI.m b/matlab/partial_information/dr1_PI.m
index b8bf5b36d072eb169c2adcb789759edeeaeb33bc..b741854968b4c091a57ee05c591756a18a6b1819 100644
--- a/matlab/partial_information/dr1_PI.m
+++ b/matlab/partial_information/dr1_PI.m
@@ -91,7 +91,7 @@ if options_.ramsey_policy && options_.ACES_solver == 0
     opt.jacobian_flag = 0;
     oo_.steady_state = dynare_solve('ramsey_static',oo_.steady_state,opt,M_,options_,oo_,it_);
     options_.solve_algo = old_solve_algo;
-    [junk,junk,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
+    [~,~,multbar] = ramsey_static(oo_.steady_state,M_,options_,oo_,it_);
     [jacobia_,M_] = ramsey_dynamic(oo_.steady_state,multbar,M_,options_,oo_,it_);
     klen = M_.maximum_lag + M_.maximum_lead + 1;
     dr.ys = [oo_.steady_state;zeros(M_.exo_nbr,1);multbar];
@@ -123,14 +123,14 @@ else
         lq_instruments.sim_ruleids=sim_ruleids;
         lq_instruments.tct_ruleids=tct_ruleids;
         %if isfield(lq_instruments,'xsopt_SS') %% changed by BY
-        [junk, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY
+        [~, lq_instruments.xsopt_SS,lq_instruments.lmopt_SS,s2,check] = opt_steady_get;%% changed by BY
         [qc, DYN_Q] = QPsolve(lq_instruments, s2, check); %% added by BY
         z = repmat(lq_instruments.xsopt_SS,1,klen);
     else
         z = repmat(dr.ys,1,klen);
     end
     z = z(iyr0) ;
-    [junk,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ...
+    [~,jacobia_] = feval([M_.fname '.dynamic'],z,[oo_.exo_simul ...
                         oo_.exo_det_simul], M_.params, dr.ys, it_);
 
     if options_.ACES_solver==1 && (length(sim_ruleids)>0 || length(tct_ruleids)>0 )
diff --git a/matlab/perfect-foresight-models/det_cond_forecast.m b/matlab/perfect-foresight-models/det_cond_forecast.m
index 1e4fe53ad659f1344d7097f06f88c7ec2a49c8dd..0819820f9eed4a55c3a79d37f02b08791095cdde 100644
--- a/matlab/perfect-foresight-models/det_cond_forecast.m
+++ b/matlab/perfect-foresight-models/det_cond_forecast.m
@@ -368,7 +368,7 @@ end
 save_options_initval_file = options_.initval_file;
 options_.initval_file = '__';
 
-[pos_constrained_pf, junk] = find(constrained_perfect_foresight);
+[pos_constrained_pf, ~] = find(constrained_perfect_foresight);
 indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
 if isempty(indx_endo_solve_pf)
     pf = 0;
@@ -572,7 +572,7 @@ else
     for t = 1:constrained_periods
 
         if direct_mode && ~isempty(is_constraint)
-            [pos_constrained_pf, junk] = find(constrained_perfect_foresight .* is_constraint(t, :)');
+            [pos_constrained_pf, ~] = find(constrained_perfect_foresight .* is_constraint(t, :)');
             indx_endo_solve_pf = constrained_vars(pos_constrained_pf);
             if isempty(indx_endo_solve_pf)
                 pf = 0;
@@ -580,7 +580,7 @@ else
                 pf = length(indx_endo_solve_pf);
             end
 
-            [pos_constrained_surprise, junk] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)');
+            [pos_constrained_surprise, ~] = find((1-constrained_perfect_foresight) .* is_constraint(t, :)');
             indx_endo_solve_surprise = constrained_vars(pos_constrained_surprise);
 
             if isempty(indx_endo_solve_surprise)
@@ -591,7 +591,7 @@ else
         end
 
         if direct_mode && ~isempty(is_shock)
-            [pos_shock_pf, junk] = find(shock_perfect_foresight .* is_shock(t, :)');
+            [pos_shock_pf, ~] = find(shock_perfect_foresight .* is_shock(t, :)');
             indx_endo_solve_pf = shock_vars(pos_shock_pf);
             if isempty(indx_endo_solve_pf)
                 b_pf = 0;
@@ -599,7 +599,7 @@ else
                 b_pf = length(indx_endo_solve_pf);
             end
 
-            [pos_shock_surprise, junk] = find((1-shock_perfect_foresight) .* is_shock(t, :)');
+            [pos_shock_surprise, ~] = find((1-shock_perfect_foresight) .* is_shock(t, :)');
             indx_endo_solve_surprise = shock_vars(pos_shock_surprise);
 
             if isempty(indx_endo_solve_surprise)
diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver.m b/matlab/perfect-foresight-models/perfect_foresight_solver.m
index c770a630a32704fa2c1b2aec9e7282a4d1ea469a..17f607ca09e6d67e338bdd086df52a9714047ac0 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver.m
@@ -179,9 +179,9 @@ if ~isreal(oo_.endo_simul(:)) %can only happen without bytecode
     yT = real(oo_.endo_simul(:,options_.periods+2));
     yy  = real(oo_.endo_simul(:,2:options_.periods+1));
     illi = M_.lead_lag_incidence';
-    [i_cols,junk,i_cols_j] = find(illi(:));
+    [i_cols,~,i_cols_j] = find(illi(:));
     illi = illi(:,2:3);
-    [i_cols_J1,junk,i_cols_1] = find(illi(:));
+    [i_cols_J1,~,i_cols_1] = find(illi(:));
     i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
     residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
                                           oo_.exo_simul,M_.params,oo_.steady_state, ...
diff --git a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m
index e20c9faf6fcbd2a5d3e82405ac6e8069f01165cc..1f55a2de48f97e8507c18b5496c59182217d94e3 100644
--- a/matlab/perfect-foresight-models/perfect_foresight_solver_core.m
+++ b/matlab/perfect-foresight-models/perfect_foresight_solver_core.m
@@ -123,16 +123,16 @@ if nargout>1
     yy  = oo_.endo_simul(:,2:options_.periods+1);
     if ~exist('illi')
         illi = M_.lead_lag_incidence';
-        [i_cols,junk,i_cols_j] = find(illi(:));
+        [i_cols,~,i_cols_j] = find(illi(:));
         illi = illi(:,2:3);
-        [i_cols_J1,junk,i_cols_1] = find(illi(:));
+        [i_cols_J1,~,i_cols_1] = find(illi(:));
         i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
     end
     if options_.block && ~options_.bytecode
         maxerror = oo_.deterministic_simulation.error;
     else
         if options_.bytecode
-            [chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
+            [chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
         else
             residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
                                                   oo_.exo_simul,M_.params,oo_.steady_state, ...
diff --git a/matlab/perfect-foresight-models/private/initialize_stacked_problem.m b/matlab/perfect-foresight-models/private/initialize_stacked_problem.m
index 1a8f61838475f954c9e3d8d311fd8108317cad36..f019805dc907a030375dc6f81c09edd8dba0f259 100644
--- a/matlab/perfect-foresight-models/private/initialize_stacked_problem.m
+++ b/matlab/perfect-foresight-models/private/initialize_stacked_problem.m
@@ -71,8 +71,8 @@ y0 = endogenousvariables(:,M.maximum_lag);
 yT = endogenousvariables(:,M.maximum_lag+periods+1);
 z = endogenousvariables(:,M.maximum_lag+(1:periods));
 illi = M.lead_lag_incidence';
-[i_cols, junk,i_cols_j] = find(illi(:));
+[i_cols,~,i_cols_j] = find(illi(:));
 illi = illi(:,2:3);
-[i_cols_J1, junk,i_cols_1] = find(illi(:));
+[i_cols_J1,~,i_cols_1] = find(illi(:));
 i_cols_T = nonzeros(M.lead_lag_incidence(1:2,:)');
 dynamicmodel = str2func([M.fname,'.dynamic']);
\ No newline at end of file
diff --git a/matlab/perfect-foresight-models/private/simulation_core.m b/matlab/perfect-foresight-models/private/simulation_core.m
index 61f6693a462317b9010c68ca5a1a90e490a14368..aa66ef2de59c347feb3364ec71acb9b49ad42137 100644
--- a/matlab/perfect-foresight-models/private/simulation_core.m
+++ b/matlab/perfect-foresight-models/private/simulation_core.m
@@ -99,16 +99,16 @@ if nargout>1
     yy  = oo_.endo_simul(:,2:options_.periods+1);
     if ~exist('illi')
         illi = M_.lead_lag_incidence';
-        [i_cols,junk,i_cols_j] = find(illi(:));
+        [i_cols,~,i_cols_j] = find(illi(:));
         illi = illi(:,2:3);
-        [i_cols_J1,junk,i_cols_1] = find(illi(:));
+        [i_cols_J1,~,i_cols_1] = find(illi(:));
         i_cols_T = nonzeros(M_.lead_lag_incidence(1:2,:)');
     end
     if options_.block && ~options_.bytecode
         maxerror = oo_.deterministic_simulation.error;
     else
         if options_.bytecode
-            [chck, residuals, junk]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
+            [chck, residuals, ~]= bytecode('dynamic','evaluate', oo_.endo_simul, oo_.exo_simul, M_.params, oo_.steady_state, 1);
         else
             residuals = perfect_foresight_problem(yy(:),str2func([M_.fname '.dynamic']), y0, yT, ...
                                                   oo_.exo_simul,M_.params,oo_.steady_state, ...
diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m
index 7fa6832d2de4c6297bb876f91a107746ac6a08f2..320fb272febfd39120672a735d63df25ae364cfb 100644
--- a/matlab/prior_posterior_statistics_core.m
+++ b/matlab/prior_posterior_statistics_core.m
@@ -204,7 +204,7 @@ for b=fpar:B
 
     if run_smoother
         [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
-        [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,junk1,junk2,P,junk4,junk5,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ...
+        [alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK,~,~,P,~,~,trend_addition,state_uncertainty,M_,oo_,options_,bayestopt_] = ...
             DsgeSmoother(deep,gend,Y,data_index,missing_value,M_,oo_,options_,bayestopt_,estim_params_);
 
         stock_trend_coeff(options_.varobs_id,irun(9))=trend_coeff;
diff --git a/matlab/realtime_shock_decomposition.m b/matlab/realtime_shock_decomposition.m
index d955b8cb65c85b5c12886714fd317d4beec0adfa..02064a7b040de274d66116479467f278dd846cb8 100644
--- a/matlab/realtime_shock_decomposition.m
+++ b/matlab/realtime_shock_decomposition.m
@@ -98,8 +98,7 @@ nobs = options_.nobs;
 if forecast_ && any(forecast_params)
     M1=M_;
     M1.params = forecast_params;
-    [junk1,junk2,junk3,junk4,junk5,junk6,oo1] = dynare_resolve(M1,options_,oo_);
-    clear junk1 junk2 junk3 junk4 junk5 junk6
+    [~,~,~,~,~,~,oo1] = dynare_resolve(M1,options_,oo_);
 end
 
 if fast_realtime
@@ -109,7 +108,7 @@ if fast_realtime
     newString=sprintf(running_text);
     fprintf(['%s'],newString);
     options_.nobs=fast_realtime;
-    [oo0,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
+    [oo0,M_,~,~,Smoothed_Variables_deviation_from_mean0] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
     gend0 = size(oo0.SmoothedShocks.(M_.exo_names{1}),1);
     prctdone=0.5;
     if isoctave
@@ -120,7 +119,7 @@ if fast_realtime
         fprintf([s0,'%s'],newString);
     end
     options_.nobs=nobs;
-    [oo2,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
+    [oo2,M_,~,~,Smoothed_Variables_deviation_from_mean2] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
     gend2 = size(oo2.SmoothedShocks.(M_.exo_names{1}),1);
     prctdone=1;
     if isoctave
@@ -142,7 +141,7 @@ for j=presample+1:nobs
     %    evalin('base',['options_.nobs=' int2str(j) ';'])
     options_.nobs=j;
     if ~fast_realtime
-        [oo,M_,junk1,junk2,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
+        [oo,M_,~,~,Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set,varlist,M_,oo_,options_,bayestopt_,estim_params_);
         gend = size(oo.SmoothedShocks.(M_.exo_names{1}),1);
     else
         gend = gend0+j-fast_realtime;
diff --git a/matlab/shock_decomposition.m b/matlab/shock_decomposition.m
index c35bf5e59dc96b61b80f2e0e28d9f9b485fc23a6..02c18a1867471b48e46eb3adee6dd2f31847ec50 100644
--- a/matlab/shock_decomposition.m
+++ b/matlab/shock_decomposition.m
@@ -72,7 +72,7 @@ end
 
 options_.selected_variables_only = 0; %make sure all variables are stored
 options_.plot_priors=0;
-[oo_, M_, junk1, junk2, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_);
+[oo_, M_, ~, ~, Smoothed_Variables_deviation_from_mean] = evaluate_smoother(parameter_set, varlist, M_, oo_, options_, bayestopt_, estim_params_);
 
 % reduced form
 dr = oo_.dr;
diff --git a/matlab/simulated_moments_estimation.m b/matlab/simulated_moments_estimation.m
index 2d90a9aaa01b7504b49a865dd3562f2d7b6746ae..4a99ec77ea55a1d07bad2459cd1591dfc6611dd8 100644
--- a/matlab/simulated_moments_estimation.m
+++ b/matlab/simulated_moments_estimation.m
@@ -97,7 +97,7 @@ if nargin>2
     if ~isunix
         error('The parallel version of SMM estimation is not implemented for non unix platforms!')
     end
-    [junk,hostname] = unix('hostname --fqdn');
+    [~,hostname] = unix('hostname --fqdn');
     hostname = deblank(hostname);
     master_is_running_a_job = 0;
     for i=1:length(parallel)
diff --git a/matlab/stochastic_solvers.m b/matlab/stochastic_solvers.m
index a3004899a49b68583d36e435a81dac98fa61926e..9f08b16010a4fd0435a064c7a97ce4f8c3741464 100644
--- a/matlab/stochastic_solvers.m
+++ b/matlab/stochastic_solvers.m
@@ -111,22 +111,22 @@ it_ = M_.maximum_lag + 1;
 z = repmat(dr.ys,1,klen);
 if local_order == 1
     if (options_.bytecode)
-        [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
-                                        M_.params, dr.ys, 1);
+        [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
+                                     M_.params, dr.ys, 1);
         jacobia_ = [loc_dr.g1 loc_dr.g1_x loc_dr.g1_xd];
     else
-        [junk,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
-                                M_.params, dr.ys, it_);
+        [~,jacobia_] = feval([M_.fname '.dynamic'],z(iyr0),exo_simul, ...
+                             M_.params, dr.ys, it_);
     end
 elseif local_order == 2
     if (options_.bytecode)
-        [chck, junk, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
-                                        M_.params, dr.ys, 1);
+        [chck, ~, loc_dr] = bytecode('dynamic','evaluate', z,exo_simul, ...
+                                     M_.params, dr.ys, 1);
         jacobia_ = [loc_dr.g1 loc_dr.g1_x];
     else
-        [junk,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),...
-                                         exo_simul, ...
-                                         M_.params, dr.ys, it_);
+        [~,jacobia_,hessian1] = feval([M_.fname '.dynamic'],z(iyr0),...
+                                      exo_simul, ...
+                                      M_.params, dr.ys, it_);
     end
     if options_.use_dll
         % In USE_DLL mode, the hessian is in the 3-column sparse representation
@@ -217,15 +217,15 @@ nz = nnz(M_.lead_lag_incidence);
 
 sdyn = M_.endo_nbr - nstatic;
 
-[junk,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
-                                                  order_var));
+[~,cols_b,cols_j] = find(M_.lead_lag_incidence(M_.maximum_endo_lag+1, ...
+                                               order_var));
 b = zeros(M_.endo_nbr,M_.endo_nbr);
 b(:,cols_b) = jacobia_(:,cols_j);
 
 if M_.maximum_endo_lead == 0
     % backward models: simplified code exist only at order == 1
     if local_order == 1
-        [k1,junk,k2] = find(kstate(:,4));
+        [k1,~,k2] = find(kstate(:,4));
         dr.ghx(:,k1) = -b\jacobia_(:,k2);
         if M_.exo_nbr
             dr.ghu =  -b\jacobia_(:,nz+1:end);
diff --git a/matlab/store_smoother_results.m b/matlab/store_smoother_results.m
index 3688dd13f20b183fd07bc81546b33ecc616ca10b..bad4fe723d2c4faeb6454de47d12291d576842f6 100644
--- a/matlab/store_smoother_results.m
+++ b/matlab/store_smoother_results.m
@@ -204,7 +204,7 @@ if ~isempty(options_.nk) && options_.nk ~= 0
         end
     else
         positions_in_declaration_order=oo_.dr.order_var(bayestopt_.smoother_var_list(bayestopt_.smoother_saved_var_list));
-        [junk,sorted_index_declaration_order]=sort(positions_in_declaration_order);
+        [~,sorted_index_declaration_order]=sort(positions_in_declaration_order);
         oo_.FilteredVariablesKStepAhead(:,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAhead;
         if ~isempty(PK) && options_.filter_covariance %get K-step ahead variances
             oo_.FilteredVariablesKStepAheadVariances(:,sorted_index_declaration_order,sorted_index_declaration_order,:)=oo_.FilteredVariablesKStepAheadVariances;
diff --git a/matlab/user_has_matlab_license.m b/matlab/user_has_matlab_license.m
index c8c681283ce8f924ed31caec0e94868d293cf0ff..6f8b3c2261a4e90eab381f14779977586f59ad73 100644
--- a/matlab/user_has_matlab_license.m
+++ b/matlab/user_has_matlab_license.m
@@ -31,7 +31,7 @@ function [hasLicense] = user_has_matlab_license(toolbox)
 if matlab_ver_less_than('7.12')
     hasLicense = license('test', toolbox);
 else
-    [hasLicense, junk] = license('checkout',toolbox);
+    [hasLicense, ~] = license('checkout',toolbox);
 end
 if ~hasLicense
     return
diff --git a/matlab/utilities/general/clean_current_folder.m b/matlab/utilities/general/clean_current_folder.m
index 6c302927e4b6e3195b04dca19e16663e410c4a11..df7e7bf790855bb53fcf43cad532ec4b357a649f 100644
--- a/matlab/utilities/general/clean_current_folder.m
+++ b/matlab/utilities/general/clean_current_folder.m
@@ -21,7 +21,7 @@ a = dir('*.mod');
 
 
 for i = 1:length(a)
-    [junk,basename,extension] = fileparts(a(i).name);
+    [~,basename,extension] = fileparts(a(i).name);
     if exist([basename '.m'])
         delete([basename '.m']);
     end
diff --git a/matlab/varlist_indices.m b/matlab/varlist_indices.m
index 91b2f6e694bf8374e7b6d0c7620ce8ba7908541e..a166f28b66ce621eedb0848dd1b38ba58947b4f2 100644
--- a/matlab/varlist_indices.m
+++ b/matlab/varlist_indices.m
@@ -48,7 +48,7 @@ if ~all(check)
 end
 
 nvar = length(i_var);
-[i_var_unique, index_uniques, junk] = unique(i_var, 'first');
+[i_var_unique, index_uniques, ~] = unique(i_var, 'first');
 index_uniques = sort(index_uniques);
 i_var_unique = i_var(index_uniques);