List of functions used in a Matlab script [duplicate] - matlab

This question already has answers here:
How can I generate a list of function dependencies in MATLAB?
(2 answers)
Closed 8 years ago.
Is it possible to obtain a list of the user-supplied functions (functions which are not Matlab toolbox functions) called by a Matlab script?

Yes. In the MATLAB Current Folder window, navigate to the folder containing your script. Right-click on the background of the window, and select Reports->Dependency Report. You should get a nice report detailing the dependencies of all the files in that folder.
You can achieve roughly the same result programmatically with the command depfun, or since version 2014a, matlab.codetools.requiredFilesAndProducts.

Related

How to close MATLAB editor window/windows using command? [duplicate]

This question already has answers here:
How to close one or all currently open Matlab (*.m) files from Matlab command prompt?
(2 answers)
Closed 4 years ago.
I want to know if there is any way to close the editor window (like function, script)using Matlab command.
Step 1. Get the editor service
editor = com.mathworks.mlservices.MLEditorServices; % main editor service
Step 2. Choose either of following depending on your requirement
editor.getEditorApplication.close; % Close editor windows (with prompt to save)
editor.getEditorApplication.closeNoPrompt; % Close editor windows

How to Load a .txt file into an matrix of matlab [duplicate]

This question already has an answer here:
read from a text file and load it into a matrix in matlab [duplicate]
(1 answer)
Closed 7 years ago.
Good day.
I would like to know how to load a .txt file in matlab. What I want is to work with text classification and guess the first thing to do is load devo my data in matlab .... but when I try to generate many files .my I just want an array containing my text.
Greetings and thanks in advance.
There's multiple functions that do that: importdata,textscan,fopen,dlmread etc.
I do not understand much from your question, but begin by reading through these documentation pages and try them to see which works best for you.

Function inside script in Matlab? [duplicate]

This question already has answers here:
In MATLAB, can I have a script and a function definition in the same file?
(7 answers)
Closed 9 years ago.
Can I have fast and short helper local function to use inside script?
Currently I have "FUNCTION keyword use is invalid here" message.
Why?
This is correct, MATLAB does not allow you to define full functions in a script. However, there are at least two solutions that may help you:
You could turn the script into a function. Workspace variables you are referring to from within your scripts would become arguments of the function, and you could return certain result variables.
If your helper function is really small, you may be able to define it in your script as an anonymous functions without the function keyword, as in poly = #(x) x.^2 + 3 * x - 4; - a polynomial function, for example.

variable becomes undeclared after some iteration in matlab [duplicate]

This question already has answers here:
Is it possible to have a workspace variable that persists across a call to clear?
(2 answers)
Closed 9 years ago.
Does MATLAB keep some variables after clearing?
Matlab: Free memory is lost after calling a function
My question is related to this post but some changes are there.
I have to use the output (the outputs are matrices generated, i.e. i am generating small matrices in every iteration) produced by previous large program, in my next iteration of large program, so when i am using the technique mentioned in the post, i am getting error that " Reference to a cleared variable", i need to keep some of the variables and some matrices generated. How to do that?
Sometimes the error occurs after 1 iteration only
Thanks
You can clear specific variables in the workspace with:
clear myvarname
You can also clear functions that might be holding persistent variables with:
clear myfunname
So - you should work out which ones you don't want (type whos to see variables in the workspace, or in a breakpoint) and clear the ones you don't need.
Another option would be to save the ones you do want, use the clear method you mentioned, then re-load.

MATLAB: how to get the list of figures [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How do I get the handles of all open figures in MATLAB
The situation is following. I run a couple of tests, which plot a lot of figures. I would like to convert them to pdf and compile into one file. Since each time I may get different type of plots and different number of plots, I need to get the list of all figures in current matlab session or workspace. Is this doable?
Thanks
h = get(0,'Children');
will put the "handles" to the figures you currently have in the variable h. get(handle) and set(handle,...) are gigantically useful in general. The handle 0 points at the root of the display, so all the figures on the display are the root's Children.