Content of std.m file

hi all,
I have datafun toolbox. However, by mistake i changed the code in std.m file(standard deviation). That would be good if anyone can tell me the content inside std.m file. thanks

Answers (1)

John D'Errico
John D'Errico on 5 Aug 2015
Edited: John D'Errico on 5 Aug 2015

0 votes

And this is why I NEVER tell anyone to edit TMW provided code. Too many novices will edit the code and blow away provided code.
Editing provided code to look at it is a BAD IDEA. If you think you want to edit the code for std, think again. Then think about it a third time if necessary. There is no need to edit std.
Instead, use the type command if you just wish to look at the code.
To recover a toolbox function, just download that toolbox again from the website. You need not download all of MATLAB.

6 Comments

To recover a toolbox function, just restore from your backup. You are keeping backups in case you have a hardware failure or make a mistake or get infected by malware, right?
The type command lists the code in the command window, but it's usually much clearer and more convenient to look at it in the editor. It's a pity MATLAB doesn't have an view-only editor mode (please tell me if it does!) - this was a really helpful feature of some programming environments such as POPLOG.
John D'Errico
John D'Errico on 5 Aug 2015
Edited: John D'Errico on 5 Aug 2015
Yes, a view-only mode for toolbox functions would be nice. They could set it up so that IF you needed to edit that code, you must do a special edit. But sorry, no such thing that I've ever seen in MATLAB.
And I do agree that a backup would be nice to have here. But it might be just as easy to download a single toolbox.
MATLAB has a view-only editor mode. It's enabled if you have your OS make the files in the MATLAB toolbox directories read-only. [I'm only slightly joking.] I thought that in some releases that was the default when you installed, but maybe I'm misremembering.
If you're editing the files in the MATLAB Editor, consider setting the Backup Files Preferences to save backup copies of the files before editing. It's not going to guard you against deliberately blowing away the contents of a file and then deleting the backups, but at some point if a user wants to shoot themselves in the foot no amount of armor will keep them from doing so.
dpb
dpb on 5 Aug 2015
I've always wondered why TMW didn't set the "read-only" bit but (at least on Windows) I don't think it ever has on installation. I surely don't recall ever having had it occur (and yes, while not a recommended practice, I have made bug fixes and enhancements on the distributed m-files since from the first installation I ever had() altho I am _*exceedingly_ careful to make backups of the originals prior to doing so and have never destroyed an original in the 25+ years).
I just checked and going back to R11, the earliest still-installed version here, and there are no m-files in the distribution that are write protected.
(*) I've also a text file that keeps track of which functions and what's been modified and a test suite or case to check whether the issue has been resolved in new releases on a new installation. Most all that were actual bugs have been; some of the enhancements may have done; some of those I've continued to carry along while others haven't bothered as the driving force behind them at the time often has gone away with the project at hand when it was an issue...the latter comes with retirement from active consulting, mostly. :)
The nice thing about the POPLOG editor, VED, was that you could give the command pved file.p (instead of the usual ved file.p) and it would start in a protected mode that prevented writing. You could therefore use it for any of your own code that you just wanted to inspect, as well as for POPLOG system files. Actually the system files were all write protected on installation as well, but using protected mode in the editor was tidier than falling back on file system protection. You could switch protected mode on and off from the editor as well.

Sign in to comment.

Categories

Asked:

on 5 Aug 2015

Commented:

on 6 Aug 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!