diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index 98ed0c0bbec9565735c547e9e791d20b4657b9e5..c5963cc36300355a670bb5c2e4fc70131d487e5b 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -66,8 +66,9 @@ addpath([dynareroot '/utilities/general/'])
 % or some MATLAB versions, and for which we provide some replacement functions
 
 if ~exist('OCTAVE_VERSION')
-    % Replacements for rows() and columns() (inexistent under MATLAB)
+    % Replacements for rows(), columns() and issquare() (inexistent under MATLAB)
     addpath([dynareroot '/missing/rows_columns'])
+    addpath([dynareroot '/missing/issquare'])
     % Replacement for vec() (inexistent under MATLAB)
     addpath([dynareroot '/missing/vec'])
     if ~user_has_matlab_license('statistics_toolbox')
diff --git a/matlab/issquare.m b/matlab/missing/issquare/issquare.m
similarity index 87%
rename from matlab/issquare.m
rename to matlab/missing/issquare/issquare.m
index 71233cbf6a4d93fc1b6190efebbf585ebfdfec07..4d4eb2b572c8a771080d57d35f8ffdc0904131af 100644
--- a/matlab/issquare.m
+++ b/matlab/missing/issquare/issquare.m
@@ -4,7 +4,7 @@ function i = issquare(A)
 %! @deftypefn {Function File} {@var{i} =} issquare (@var{A})
 %! @anchor{issquare}
 %! @sp 1
-%! Returns 1 if @var{A} is a square matrix, 0 otherwise.
+%! If @var{A} is a square matrix, returns its dimension; otherwise return 0.
 %! @sp 2
 %! @strong{Inputs}
 %! @sp 1
@@ -17,7 +17,7 @@ function i = issquare(A)
 %! @sp 1
 %! @table @ @var
 %! @item i
-%! Integer scalar (0 or 1).
+%! Integer scalar.
 %! @end table
 %! @sp 2
 %! @strong{This function is called by:}
@@ -45,4 +45,8 @@ function i = issquare(A)
 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 
 d = size(A);
-i = (length(d)==2) && (d(1)==d(2));
\ No newline at end of file
+if (length(d)==2) && (d(1)==d(2))
+  i = d(1);
+else
+  i = 0;
+end