Determine size of Stateflow Subchart - matlab

I am writing a Model Advisor check right now and I need to know the size of a subcharted Stateflow State or Box. But the "Stateflow.State" and "Stateflow.Box" objects only have a "Position" attribute, which gives their position inside their parent elements. I need to know the size of the subchart itself (where their contents reside). How can I get this size?

The "Position" attribute is the absolute position of "Stateflow.State" inside the Chart.Here is an example:
___________________
|AA |
|___________ |
||BB | |
||_________| |
-------------------
AA = r.find('-isa', 'Stateflow.State', 'Name', 'AA').Position
AA = 330.0924 542.7458 157.4576 94.6164
BB = r.find('-isa', 'Stateflow.State', 'Name', 'BB').Position
BB = 334.5304 571.1490 115.7404 62.6628

I finally asked the MathWorks support for a solution and got this answer:
[...] there is currently no API functionality to retrieve the size of the subchart in the subchart subviewer. Unfortunately there are no workarounds to access this information currently.
Update: I recently learned about the undocumented sf API. It is possible to get information about the subchart with it. Therefore you need to get the ID of the State whos dimensions are needed. Here is an example:
r = sfroot;
s = r.find('-isa', 'Stateflow.State', '-and', 'IsSubchart', 1);
sf('get', s(1).id, '.subviewS.pos')
This does the following:
Store the Simulink.Root object in r.
Find all subcharted States and store them in s. You might need to refine the search to detect the exact State you need.
Use the sf API to retrieve the position .pos of the first Subchart, which is represented by .subviewS
There is plenty of information about each of the Stateflow objects. To investigate further, you just need to find the appropriate object (using r.find()) and use sf('get', <object>.id). This lists all available information about the Stateflow object <object>.

Related

Linking multiple custom variables in Omniture

I have an implementation in Sitecatalyst, where i have to track categories and the multiple tags associated with the categories. How should i go for it. What should be the variables which should be defined for it in omniture.
for example -
|---------------------|
| MOOD | // Main Category
|---------------------|
| Uplifting | // Sub Category
|---------------------|
| Fun | // Sub Category
|---------------------|
| Proud | // Sub Category
|---------------------|
| Fun | // Sub Category
There are three options:
Listprop
You could create a listprop which you can enable in the report suite settings by implementing a delimiter for the traffic variable. This is especially handy if you have the possibility to create multiple levels. You can then implement the traffic variable like so:
s.prop1 = "MOOD|Uplifting|Fun|Proud|Fun";
Adobe Analytics will automatically split the values based on the pipe character. Please note that listprops don't allow correlations and pathing.
Multiple traffic variables/props
The other option would be to create multiple traffic variables and define all of them on every page where they're required.
s.prop1 = "MOOD";
s.prop2 = "Uplifting";
s.prop3 = "Fun";
s.prop4 = "Proud";
s.prop5 = "Fun";
However, this option will consume a lot of traffic variables of which you only have 75.
Classification
The third option would look the same as the listprop, however, you don't configure the traffic variable as a listprop, you configure it as a normal traffic variable and classify it later on using the Classification Rule Builder.
Using the classification rule builder you can split the incoming data by the pipe character (using regular expression) and create new dimensions resembling the categories.
s.prop1 = "MOOD|Uplifting|Fun|Proud|Fun";
I would personally go for the third option as it doesn't require a lot of props and it allows for a future proof approach of measuring the categories even when you're adding more levels.
Good luck with your implementation!

Exporting the output of MATLAB's methodsview

MATLAB's methodsview tool is handy when exploring the API provided by external classes (Java, COM, etc.). Below is an example of how this function works:
myApp = actxserver('Excel.Application');
methodsview(myApp)
I want to keep the information in this window for future reference, by exporting it to a table, a cell array of strings, a .csv or another similar format, preferably without using external tools.
Some things I tried:
This window allows selecting one line at a time and doing "Ctrl+c Ctrl+v" on it, which results in a tab-separated text that looks like this:
Variant GetCustomListContents (handle, int32)
Such a strategy can work when there are only several methods, but not viable for (the usually-encountered) long lists.
I could not find a way to access the table data via the figure handle (w/o using external tools like findjobj or uiinspect), as findall(0,'Type','Figure') "do not see" the methodsview window/figure at all.
My MATLAB version is R2015a.
Fortunately, methodsview.m file is accessible and allows to get some insight on how the function works. Inside is the following comment:
%// Internal use only: option is optional and if present and equal to
%// 'noUI' this function returns methods information without displaying
%// the table. `
After some trial and error, I saw that the following works:
[titles,data] = methodsview(myApp,'noui');
... and returns two arrays of type java.lang.String[][].
From there I found a couple of ways to present the data in a meaningful way:
Table:
dataTable = cell2table(cell(data));
dataTable.Properties.VariableNames = matlab.lang.makeValidName(cell(titles));
Cell array:
dataCell = [cell(titles).'; cell(data)];
Important note: In the table case, the "Return Type" column title gets renamed to ReturnType, since table titles have to be valid MATLAB identifiers, as mentioned in the docs.

Graph representation - display individuals by data property and group by type

I currently use OntoGraf 1.0.3 (via "Class views"/"OntoGraf") to display a small ontology created in Protege 5 beta-17 as a graph; not out of choice but because it is the first tool I found.
My chosen display mode is "Horizontal Directed". Unfortunately, within a layer the order of items appears to be random; it would help clarity if they could be grouped by their type.
Is this possible and how?
Furthermore, nodes in the graph are displayed by their URI. All individuals have a data property "Name" however, and I would like those to be labelled with that property instead of their URI.
Is this possible and how?
Bonus question:
When displaying the whole ontology, layers of the tree are strictly arranged based on relation jumps; I would like to push individuals below the deepest class layer.
To elaborate, this is how it looks like:
C
|\
C I <- same layer, no correlation
/| |
I C I <- same layer, no correlation
This is how I would like it:
C
|\
C \
/| |
| C |
I I <- same layer, same level of abstraction
|
I
If there is a better solution to produce a graphical tree with such characteristics, I will gladly accept that instead.

Remove Matlab r2014b Plot Browser limit

Among many distressing graphics changes to r2014b, the Plot Browser now only displays a certain number of lines per plot (looks like the limit is 50). Any number of plots above this limit are not displayed in the Plot Browser - it just says "and 78 more..."
Is there anyway to remove the limit? I want to see all my lines in the plot browser.
Unfortunately the answer is currenty:
No you cannot remove this limit
This was already reported to mathworks a while ago, and here is the reply:
I am writing in reference to your Technical Support Case #01143663
regarding 'plot browser with "and xxxx more...." indication'.
Really interesting question (and even a bit surprising). Basically
this limitation has been introduced with MATLAB 2014b!
Our developers are aware of that, and they are working to solve it. An
enhancement/bug request has been already submitted, and I am going to
add this case to the list. However, I cannot guarantee you a release
date.
If you think this limitation is crucial for your work, I would
strongly suggest you to contact your account manager, which will have
a bit more influence on the developers than a simple engineer :).
Of course, if there is anything else I can do for you, please let me
know
So it seems that you will have to deal with this limitation if you keep using 2014b.
This was also an issue for me; in particular I wanted to see the DisplayName property of the graphics object in the list. I used a workaround where I created a callback function, so that when clicking on a data point, the DisplayName would be shown. This can be helpful if you have a plot of many lines and want to see the DisplayName of a particular one. You would first need to set the DisplayName property of the graphics objects for this to work, as it's empty by default. You could also use this to show other properties, such as Color or LineStyle, that are shown in the plot browser:
%Based on
%http://www.mathworks.com/help/matlab/ref/datacursormode.html
%'fig_h' is the figure handle
dcm_obj = datacursormode(fig_h);
set(dcm_obj,'UpdateFcn',#myupdatefcn)
And then include this function as a separate file on the Matlab path, or paste into the function you're currently writing, and include an extra 'end' at the end of that function:
function name = myupdatefcn(empt,event_obj)
% Customizes text of data tips
tar = get(event_obj,'Target');
name = get(tar,'DisplayName');
end

pygraphviz/networkx external label (xlabel)

I have a question regarding external labels in pygraphviz. Sadly, I haven't found anything regarding this on the internet.
I want to use networkx to create/parse a graph in tree structure and then use pygraphviz/pydot to draw it. I need external labels on top of the normal labels for the nodes because I want to display values for the nodes + the node name itself.
Let's say I have the following graph (very simplified example of what I'm doing later):
g = nx.Graph()
g.add_edges_from([('A','B'), ('A','C')])
p = nx.drawing.nx_pydot.to_pydot(g)
So I'm using the last line to generate a tree like hraph and I need external labels for B and C.
How to do it?
For pygraphviz you can pass through arbitrary graphviz attributes, so you can do:
dot.node('point', '', shape='point', xlabel='Label')