What is the return type of the imshowpair command in matlab - 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.

Related

Simulink & Masks: Dynamic access to parameters "evaluate" and "tunable"

First of all, matlab version is 2011b, so I cannot use Simulink.MaskParameters class.
I have one simulink mask and some parameters inside. I need to determine in my function for each parameter if it is "evaluable" or "tunable".
Those two things are two checkboxes in the mask parameters dialog which you can select for any parameter.
For "tunable", there's the MaskTunableValues property. For "enable", there's the "MaskEnables" property.
Do you know if there's a way to programmatically access the same property but for "evaluate" ?
Thanks
#Phil Goddard's answer shows you how to find the parameter. To complete the answer, the actual parameter is MaskVariables. Evaluate flag is embedded into the MaskVariables string. It is not straightforward to modify this. For example for two parameters MaskVariables string contains something like this:
"a=#1;b=&2;"
In this string the # sign indicates evaluation. Based on that, parameter a is evaluated and parameter b is not. If you want to change the evaluate flag, you need to set this string for MaskVariables parameter exactly how it was except for # or & signs.
For more information see R2011b documentation for mask parameters at https://www.mathworks.com/help/releases/R2011b/toolbox/simulink/slref/f23-18517.html. Towards the bottom of the page there is more detail about MaskVariables parameter.
You're using too old a release for most people to be able to give you an exact solution, however, I'm sure (from memory) that this parameter is available.
If you click on the mask to select the block, then go to the MATLAB command line and type
get_param(gcb,'ObjectParameters')
you'll get a list of all the block properties. (You may already know that since you're aware of MaskTunableValues and MaskEnables.) Near the bottom of that list are all of the properties related to the mask.
Now manually look at each/all of those properties, e.g.
get_param(gcb,'MaskTunableValues')
and you'll find that one of them is a structure that contains the information that you're looking for. (You may need to dig down into the structure to find the specific info.)
Answer for versions > 2011b (tested on 2014b):
Ok found it, actually the matlab documentation is REALLY unclear regarding the Simulink.MaskParameter class and here is how it works:
First, get the Mask class from your block:
mask = Simulink.Mask.get(gcb)
The Mask class is a structure containing all mask parameters:
parameters = mask.Parameters(:)
parameters is a (array of) Simulink.MaskParameter object which will contains all the necessary properties, including Evaluate.

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 .

Use command line to browse LinearModel object properties

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)

Custom classes data tooltips in Matlab editor

Does any one would know a way of overriding the data tooltip that is shown when hovering over a variable when we are in the Matlab editor ? I have a custom class that is relatively simple and its content could be shown easily in the tool tip, but Matlab insists on saying it is a 1x1 CustomClass, which is nice and all, but it would be more useful if we could make it to show the content of the object in a nice way. Right now, I have to type the name of the variable in the cmd window e.g. when debugging instead of a short hover on the variable name. Nitpicky, but I'd find it interesting ^^
I've tried to dig a bit using undocumented leads on data tooltips, e.g. http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/
http://undocumentedmatlab.com/blog/spicing-up-matlab-uicontrol-tooltips/
But I don't have the final answer, anyone has any ideas ?
The tooltip seems to get its string by using the disp method. Override disp on your class. In the method body, construct your desired string however you want and then call disp on it. In R2012a at least this works for the debugger tooltip.
Note that you'll need to do a clear classes after editing the class to get MATLAB to recognize the overridden disp.

Pass variable from GUI to function in MATLAB

I have a MATLAB GUI that loads to aid in visually pre-processing data. Essentially it prompts the user to adjust the data range, reduce number of data points, etc... all while providing an updated graph. Upon completion of this work, I want to be able to close out the GUI and pass variables from the GUI to another MATLAB function that does the data analysis. I have found lots of information on how to pass information from a function TO and GUI, but not the other way around.
Any help would be greatly appreciated.
Global variables can cause hard to find bugs. The best solution for your problem (where you want to pass the data directly to another function on close) might be to call the analysis function from the Figure Close Request Function. When the figure your GUI is running in is told to close, it will run the code in this function, which can call your analysis function and have access to the GUI's data.
Matlab GUIs are functions: the code exists in a .m file just like other functions. Like regular functions, they can have return values. You can get as fancy as you want messing with the varargout system, or you can simply return a value, structure, or cell array containing whatever you want. Open up the m-file and edit it to return what you want it to.
Note: If you require special processing when the figure is being closed to generate the appropriate return value, you can reimplement the closeRequestFcn as you see fit.
The easy way: you declare as global variable, where variable stores the data that you want to carry from the GUI to the main MATLAB workspace. Then, you also declare the same global variable on the command window. Hereinafter, variable to be accesible from both scopes, the GUI and the main workspace.
You could also use save or any other alternatives as csvwrite or dlmwrite to store the data into a file, but this doesn't seem to be your case.