diff --git a/dlib/matlab/mex_wrapper.cpp b/dlib/matlab/mex_wrapper.cpp index a82bdac6f..7d7ea9927 100644 --- a/dlib/matlab/mex_wrapper.cpp +++ b/dlib/matlab/mex_wrapper.cpp @@ -387,6 +387,29 @@ namespace mex_binding return escape_percent(sout.str()); } +// ------------------------------------------------------- + + template < + typename matrix_type + > + typename dlib::enable_if_c::value || is_array2d::value >::type + clear_mat ( + matrix_type& m + ) + { + m.set_size(0,0); + } + + template < + typename matrix_type + > + typename dlib::disable_if_c::value || is_array2d::value >::type + clear_mat ( + matrix_type& + ) + { + } + // ------------------------------------------------------- template < @@ -651,6 +674,12 @@ namespace mex_binding } else if (is_matrix::value || is_array2d::value) { + if (prhs == NULL) + { + clear_mat(arg); + return; + } + typedef typename inner_type::type type; const int num_dims = mxGetNumberOfDimensions(prhs);