Rebuilt inline function - standard deviation

I want to have a std.m file for standard deviation. It is in the fun fun dataset, but by mistake I changed the code and the std command no longer works. How to run the original std (standard deviation) command?

+4
source share
1 answer

Retrieving all the comments, the std.m function is actually extremely simple:

 function y = std(varargin) y = sqrt(var(varargin{:})); 

This is the definition of standard deviation : the square root of Variance .


  • Set inline functions Read only

Now don’t break the var.m file because it is more complex and I wonder if the copyright issue will be displayed here.

To avoid the problem of splitting embedded files, it is recommended that you install all Matlab tool files as Read-Only . I remember the old Matlab installer, which makes it possible to do this during installation. I don’t know if the installer offers an option, but if it’s not so easy to do it manually (on Windows just select your folders, right-click Properties , select only read and accept to distribute the properties to all subfolders and files).


  • Overload

Once this is done, your embedded files will be safe. You can change the default behavior of an inline function by overloading it. This consists of writing a function with the same name and organizing its call to the default function (your overload function becomes standard).

This article explains how to overload user-defined functions.

Matlab does not recommend directly overloading built-in functions (instead, for example, calling it a different name, for example mySTD.m ), but if you insist that it is feasible and is still much better than changing the built-in function ... at least , the original function is still not installed.

+6
source

All Articles