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: icassoDendrogram.m
    path of file: ./repos/fit/FITv2.0e/ica_fuse/toolbox/icasso122
    
    the code of the file until where you have to start completion: function icassoDendrogram(sR,L)
%function icassoDendrogram(sR,[L])

    
function icassoDendrogram(sR,L)
%function icassoDendrogram(sR,[L])
%
%PURPOSE 
%
%To visualize the clustering and similarities between estimates as
%a dendrogram and a corrgram.
%
%EXAMPLE OF BASIC USAGE
%
% icassoDendrogram(sR,25)
%
%INPUT 
%
%[An argument in brackets is optional. If it isn't  given or it's
% an empty matrix/string, the function will use a default value.] 
%
%sR  (struct) Icasso result data structure; clustering has to be readily
%      computed.
%[L] (scalar) number of estimate-clusters. Default: the (reduced)
%      data dimension. 
%
%DETAILS
%
%Plots dendrogram (tree visualization) of the clustering hierarchy
%and a corrgram (the values of similarity matrix visualized as a
%gray level matrix). The entries in the corrgram are ordered
%according to the leaf ordering in the dendrogram. The clusters in
%the corrgram are indicated by red lines.  
%
%SEE ALSO
% icassoGraph 
% icassoShow
% som_dendrogram
% hcluster

%COPYRIGHT NOTICE
%This function is a part of Icasso software library
%Copyright (C) 2003-2005 Johan Himberg
%
%This program is free software; you can redistribute it and/or
%modify it under the terms of the GNU General Public License
%as published by the Free Software Foundation; either version 2
%of the License, or any later version.
%
%This program is distributed in the hope that it will be useful,
%but WITHOUT ANY WARRANTY; without even the implied warranty of
%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with this program; if not, write to the Free Software
%Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

% ver 1.2 johan 100105

%% Check that clustering info is present
if isempty(sR.cluster.partition) | isempty(sR.cluster.similarity), 
  error('Missing clustering information.');
end

% Get default cluster number
if nargin<2|isempty(L),
  L=max(icassoGet(sR,'rdim'));
  disp([sprintf('\n') 'Number of estimate-clusters not given: using (reduced)' ...
	  ' data dimension.']);
end