Streamlined code by removing unnecessary conditions.

time-shift
Stéphane Adjemian (Charybdis) 2018-01-24 15:59:04 +01:00
parent 92549e48b1
commit 145f1e7b1c
1 changed files with 4 additions and 8 deletions

View File

@ -44,12 +44,8 @@ function c = demean(x)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
if ndim(x)>2
error('This function is not implemented for arrays with dimension greater than two!')
end
if ndim(x)==1
c = x-nanmean(x);
elseif ndim(x)==2
c = bsxfun(@minus,x,nanmean(x));
else
error('descriptive_statistics::demean:: This function is not implemented for arrays with dimension greater than two!')
end
c = bsxfun(@minus, x, nanmean(x));