Veiwing the source code for a function in Matlab?

271 views (last 30 days)
Yildirim Kocoglu
Yildirim Kocoglu on 30 Jan 2019
Edited: Yildirim Kocoglu on 30 Jan 2019
I am aware that there is an option to look into the source code of a function in Matlab by typing the code below:
open functionx
(functionx above can be any function that I'm interested in):
I was able to look into the source code for the specific function that I wanted so my question is not how to do it.
My question is: Are there certain functions which I can't see the source code due to commercial reasons?
If yes, is there a faster way of knowing which function source codes I can't view/open in matlab? Is there a list avaiable somewhere?
To narrow the list down, I'm specifically interested in functions that are related to statistics and machine learning.
The reason I'm interested in veiwing the source code for these functions is understanding the Machine learning/Statistics concepts better while reading through the theory.
Second Queston:
I'm also interested in the list of available functions (all) for machine learning and statistics.
Is there a list available for these functions in the matlab 2018a version?
Any help is appreciated.
Yildirim Kocoglu
Yildirim Kocoglu on 30 Jan 2019
I‘m not planning to do anything with the copyright code other than use it for learning. I was just curious if anyone has come across a built-in function in these toolboxes that can’t be viewed but, you are right: It’s probably a better idea to ask this question directly. Thanks.

Sign in to comment.

Accepted Answer

Jan on 30 Jan 2019
Do you have Matlab installed already? Then you can check tis easily by your own: Search the folder in Matlab's installation folder, which contain the wanted toolboxes. If it is e.g. "stat":
List = dir(fullfile(matlabroot, 'toolbox', 'stat', '**', '*.m'));
Now you have a list of all M-files. Some of them might contain the help text only, while the actual code is compiled. You can look into the files manually or read them in a loop:
for k = 1:numel(List)
File = fullfile(List(k).folder, List(k).name);
Data = strsplit(fileread(File), '\n');
Data = strtrim(Data);
Data(strncmp(Data, '%', 1)) = [];
n = nnz(cellfun('length', Data));
if n > 0

More Answers (0)




Community Treasure Hunt

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

Start Hunting!