Use command line to browse LinearModel object properties - matlab

I'm following the regression tutorial at http://www.mathworks.com/help/econ/estimate-regression-model-with-multiplicative-arima-errors.html. In particular, I am browsing the object Fit=fitlm(X,logY). I know I can double-click the object in the Workspace window, but I often don't want more windows. I might just want to list the members at the command line. According to http://www.mathworks.com/help/ident/ug/linear-model-structures.html#bq4gq_u-20, I should be able to do this with the get method. However, Matlab informs me that the Linear Model class doesn't have a get method [tried Fit.get, Fit.get(), and get(Fit)]. What am I missing?
As for browsing the properites using the GUI window, I'm finding that the Residuals property is not present. According to http://www.mathworks.com/help/stats/linearmodel-class.html, it should be present. Thanks for any light that can be shed on my misunderstanding of the class.
I've posted this at:
http://groups.google.com/forum/#!topic/comp.soft-sys.matlab/b0jHdrX6_ZY

You can list all the property names of an object using the properties function. In your case:
properties(Fit)

Related

MATLAB member function suggestion

If for example you have acquired a object of type handleplot with expression like below:
handle = plot(t,functoin1 , t , function2 ) ;
Now handle will be an array that contains two elements, handle(1) and handle(2). Now suppose you want to change some properties of one of these objects, like set a LineWidth, change the Color, or the like.
Is there any way in which you can activate auto-completion or suggestions when you type handle(1). (note the memebership operator .)? I am looking for the automatic suggestions that MATLAB provides for member functions in a combobox near the blinking cursor, similar to the way other IDEs provide this feature:
MATLAB's objects support tab completion. After typing handle(1). simply hit tab and you will receive a list of available methods and properties of the graphics object.
If you want more help on a method, you will also get a popup dialog of the method and the accepted input arguments.
If you want to programmatically get a list of properties of an object, you can use properties
properties(t)
If you want a listing of all properties and their values, just use get
get(t)
i use this method ...
for example i'm writing a program in matlab editor and when im want to know the properties of an object just stop coding and run the program , know it's have my object (for example handle) and know i can write the properties(handle) in command window to know the exact properties of handle . as Suever says .

What is the return type of the imshowpair command in matlab

I have tried all possible means to figure out the return type of imshowpair command in MATLAB but I still was not able to find its return type.
I would be very thankful if someone could tell me its return type.
In the future, using class is a very easy way to determine the type of a variable that is returned by a function.
According to the documentation, the output of imshowpair is simply the graphics handle to the image object that is created.
h = imshowpair(rand(10), rand(10));
class(h)
matlab.graphics.primitive.Image
You can use this graphics handle to change the appearance of the displayed image. You can call get(h) to get a list of all properties you can get/set and their current values. The documentation for the image object provides a complete list along with the description of each of these properties.
There are three major ways to do so:
Thanks to the help. By browsing the help page for imshowpair(), which can be found here, you can click on the output h and the hyperlink will show you some infos about it which, in this case, is:
handle to Handle Graphics image object.
Image object, returned as a
handle to the Handle Graphics image object created by imshowpair.
Thanks to the Workspace. In Matlab you can setup your window layout in order to show the Workspace that is a list of all the Matlab variables you have in memory. In the Workspace you can as well show the class (type). In this case you'll see something like (excuse my tiny Workspace window):
Thanks to the class() function. I have C as output from imshowpair() and by typing class(C) I get:
matlab.graphics.primitive.Image
which is the same result as in the Workspace case.

MATLAB doesn't show help for user-created class private methods and properties

This is the problem:
Create a class and set the access to be private for some of the properties or methods.
Use the doc command for the created class. This will auto-generate documentation from your comments and show it in the built-in help browser.
doc classname
The problem is that documentation for the private properties and methods is not shown in the help browser. Is there any way to overcome this problem?
So I spent like 10 minutes using the debugger, jumping from one function to the next, tracing the execution path of a simple doc MyClass call.
Eventually it lead me to the following file:
fullfile(toolboxdir('matlab'),'helptools','+helpUtils','isAccessible.m')
This function is called during the process of generating documentation for a class to determine if the class elements (including methods, properties, and events) are publicly accessible and non-hidden. This information is used later on to "cull" the elements.
So if you are willing to modify MATLAB's internal functions, and you want the docs to always show all methods and properties regardless of their scope, just rewrite the function to say:
function b = isAccessible(classElement, elementKeyword)
b = true;
return
% ... some more code we'll never reach!
end
Of course, don't forget to make a backup of the file in case you changed your mind later :)
(on recent Windows, you'll need to perform this step with administrative privileges)
As a test, take the sample class defined in this page and run doc someClass. The result:
This behaviour is by design - the auto-generated documentation is intended for users of the class, who would only be able to access the public properties and methods.
There's no way that I'm aware of to change this behaviour.
You could try:
Use an alternative system of auto-generating documentation such as this from the MATLAB Central File Exchange (which I believe will document all properties, not just public).
Implement your own doc command. Your doc command should accept exactly the same inputs as the built-in doc command, detect if its inputs correspond to your class/methods/properties etc, and if so display their documentation, otherwise pass its inputs straight through to the built-in doc. Make sure your command is ahead of the built-in on the path.

hierarchy of functions in MatLab

I have been reading someone else's matlab code and I don't know how the code structured. I mean I would like to know the hierarchy of functions, which function uses which function. I am reading the code to figure that out but its taking a lot of time.
So is there any other way I can see this hierarchy without reading the whole thing? To be honest it is starting to get confusing. Maybe MatLab has a built in function for that! I found this:
How can I generate a list of function dependencies in MATLAB?
but this doesn't seem to be helpful!
The MATLAB profiler will show you what functions are called by your code (and much more information to boot) and allow you to click through the hierarchy of function calls. You can either call profile on and then run your code, then call profile off and profile viewer, or you can simply call profile viewer and type a single line of code to run in the edit box at the top.
Use the dependency report provided in MATLAB:
http://www.mathworks.co.uk/help/matlab/matlab_prog/identify-dependencies.html
There are also some tools on the File Exchange, such as fdep.
No idea about a function to show visible or depended-upon functions. However the basic rules are:
1) Only the first function in a .m file (normally has to have the same name as the file itself) is visible outside that file.
2) Any function can see any top level (see 1.) function if the file is in the matlab path. Matlab can show you the path so you know where it's hunting.
3) The order of the path is important, the first instance of a function called foo found in the path will be called. Obviously the current directory is at the top of the path.
3) All functions in a given file can see all other functions in that file.
That's the basics. No doubt there are other rules, and possibly exceptions to this. But that understanding generally serves me well.
Obviously the easiest way to work out which function is being called is to click on it in the editor and open it.
One thing I do is simply place in each function at the beginning fprintf("inside function <name>/n"); and at the end of the function fprintf("leaving function <name>/n"); where <name> is the name of the function.
This will give you a very specific list of which function is being called by which function (based on the order that they appear). Another thing like this would be to place fprintf("function <name1> calling function <name2>/n"); so you can be more explicit about which function is being called by which one.

Lazarus: How do I find detailed docs (class info) of objects?

Is there a way to find complete class info of an object in Lazarus. F1 doesn't work.
For example, I want to know the methods, events and properties of TSQLQuery. More specifically, I'm trying to find what constants I can use with the state property.
The docs I've found so far aren't really much help in this context.
I've also tried the menu that says 'object browser' but it simply points to the properites window.
TSQLQuery and its unit sqldb is not documented.
The state property however is from the base tdataset ancestor of sqlquery, and that IS documented.
Try typing TDatasetstate or tdataset and press F1
The best documentation is the source code. After you dropped a TSQLQuery on the form CTRL-click on the identifier "TSQLQuery" in the source editor. Lazarus will open the corresponding source file at the position where TSQLQuery is declared. Scroll down to the public methods or published properties to see everything you need. Identifiers usually are self-explanatory - the chm file often does not contain more info. And the source is always up-to-date.
You can do the same with any identifier. Depending on the Lazarus version you may land in the implementation part of the unit. In this case, just press SHIFT-CTRL Up/Down to go to the interface.