Sparx Enterprise Architect: SysML IBD - How to display nested sub-blocks as boxes (rectangles)? - enterprise-architect

I have an IBD defining the content of block, which includes nested blocks, where:
Block A - shown as a box (rectangle)
Block A contains:
Block A1 shown as a box (rectangle)
And Block A1 contains
Block X
Block Y
Block Z
where all three of Block X, Block Y, and Block Z are displayed as just text under the parts heading
Question: How can I make EA display Block X, Block Y, and Block Z as boxes (rectangles)?

In the IBD select :Block A1.
In the Parts/Properties tab in the Features window (right click->Features->Parts/Properties) you should see Block X, Block Y, Block Z. Note there is a column for Visible in which all entries should be False.
To show Block X, Y and Z as nested rectangles on the IBD just click on the checkbox for each row.

Related

Matlab: how to set logarithmic scale on the coutour plot

I have some data that I want to display as contour plot with logarithmic scale of the values (the matrix Z) and labelled countours. This is how I do it:
[C, h1] = contourf(X, Y, log(Z));
clabel(C,h1);
Here is my result:
My question is: how can I get the right labels on the contours? I don't want a color bar as described here.
Edit: Here is my example:
X = 1:1:20;
Y = X;
Z = zeros(size(Y));
for i = 1:size(Y,2);
Z(i, :) = 10^i;
end
[C, h1] = contourf(X, Y, Z);
clabel(C,h1);
My true data looks like this:
I can set any countour lines labels I want, but they won't be visible since my data is exponential (And by the way, the labels that are visible in this plot, are the true ones, the ones I want to get on the next plot).
Now, since my data in exponential, I have to use the logarithmic scale on the displayed values (the matrix Z) to show the data properly. Here is how I do it (maybe there is another, better way, I don't know, I haven't found anything else):
[C, h1] = contourf(X, Y, log(Z));
clabel(C,h1);
Here is how my picture looks like:
And it looks well now - you can see how my data varies. However, the labels are wrong. I can now set them to any vector you like:
0:5:45 - and I'll get exactly what I have now.
10^[0:5:45] (these labels I'd like to have). But now my plotted data rang is (0, 45) (because I calculated the logarithm of it). So, most of the labels won't be shown (they exceed data range) and the one that will, will be misplaced.
Ideally, I'd like to be able to something like this:
[C, h1] = contourf(X, Y, Z, 'ZScale', 'Log');
clabel(C,h1);
and get the picture at the bottom with labels 10, 10^5, 10^10, etc.
Summing up, I need to do one of the following:
Find a way to set the logarithmic scale programmatically and let matlab worry about the isolines.
Be able to manually change the label on the isolines without moving them (new_label = 10^old_label).
A little 'Hack' that will work, although it will not be possible to keep the labels as nice as they are with a call to clabel(C,h1) :
The first step consists in calculating the values of the contour lines. You say you want them to be placed at 1,10,... and so on so you just need to find the first power of 10 bigger than the maximum of your data :
nextpow10Z=ceil(log10(max(Z(:))));
Now call contourf with the vector of contour line values :
[C,h1]=contourf(X,Y,log10(Z),1:nextpow10Z);
Now instead of calling clabel(C,h1);, we need to use another syntax of clabel that will allow us to loop trough the texts (The downgrade is that they'll be less pretty) :
tl=clabel(C);
Now if you go see the description of tl, you'll see that it's a Data object, containing Text and Line elements.
The next step consists in selecting all the elements of Type Text contained in tl :
TextElements=findobj(tl,'Type','Text');
Finally, The last step will be to loop over these and replace the numbers N with 1EN :
for i=1:length(TextElements)
TextElements(i).String=strcat('1E',TextElements(i).String);
end
And voila!

Matlab Surface Plot

I have a set of data points, x, y, and z contained in a matrix, record.
In record, each row is a data-point where the first value is the x-coordinate, the second is the y-coordinate, and the third is the z-coordinate. I would like to represent this as a surface plot. I tried:
surf([record(:,1), record(:,2)], record(:,3))
But the results were not what I expected. Any advice?
Try this code for instance.
[x,y,z]=sphere(n);
surf(x,y,z);
axis equal
This code plots with 3 parameters surf the surface of a sphere. As far as I understood from your code you want to utilize the 2 parameters surf for your application.
According to surf help when utilizing 2 parameters surf:
surf(Z) and surf(Z,C) use x = 1:n and y = 1:m. In this case,
the height, Z, is a single-valued function, defined over a
geometrically rectangular grid.
where:
The color scaling is determined
by the range of C
It just doesn't look like you want to utilize C as the color scaling parameter. For better understanding, can you send the contents of record for reference?

Annotation - Enforce a square using imrect

I have a Matlab program that asks the user to draw a rectangle around a human on the scene (I later extract that region using imcrop). I need to enforce the user to draw a square. I am using the imrect function, but I am unable to force a square, nor find documentation on how to do it.
It seems imrect can take a position-constraining function as an input argument. This function is specified as follows:
Whenever the object is moved because
of a mouse drag, the constraint function is called using
the syntax:
constrained_position = fcn(new_position)
Position is a vector of the form [xleft ybottom width height].
So try this:
axis equal %// same sccale on both axes
axis manual %// freeze axes size
h = imrect('PositionConstraintFcn', #(x) [x(1) x(2) min(x(3),x(4))*[1 1]])
The simplest way would be to set the setFixedAspectRatioMode method to true during the rectangle creation, initially drawing a square. (Check here).
Example:
%// Make sure it's initially a square!!
hRect = imrect(gca, [10 10 100 100]);
setFixedAspectRatioMode(hRect,1)
Then no matter how you change the position, it will remain a square. Note, however, that as opposed to Luis' solution the user can't specify the initial placement of the square.

Select input pixel of image by mouseclick in Matlab

I am trying to implement a tracking program using the Mean-Shift algorithm in Matlab. The idea is that, given the first frame of one video, the user can click on top of any object he wants and the program will track it all through the video sequence. I have already implemented and working the tracking part, but I am having problems giving the user the possibility to click on top of the image to select the initial pixel for the tracking algorithm.
I have thought about input function, but I don't know how to make it work. How can I display an image and click on top of a pixel and get its coordinates [x,y] to initialize the program?
You could use ginput (Graphical input from mouse or cursor)
Read any image and show them using imread and imshow
h = imread('hestain.png'); % any input image
imshow(h);
Get the coordinates using ginput, where the input argument corresponds to the number of user clicks recorded.
[x,y] = ginput(1); % getting coordinates from user
To obtain the pixel value, we need to pass the coordinates as indices of the image. To do this, the output arguments from the ginput which are double by default, must be converted to unsigned integers.
Also, x and y represents horizontal and vertical by default. But matlab syntax takes first dimension as rows (number of horizontal lines calculated vertically). Hence y value is passed as first dimension. Similarly x value as second dimension.
pixelValue = h(uint8(y),uint8(x)); % using coordinates as indices

matlab: area under overlapping circles

I have a question to you...
Imagine square with size A x A. Now lets simulate circles with diameter of d, randomly distributed within this square, something like on the image below (in this case d's are the same, but its not the rule, they might be also randomly distributed within some range like d1 to d2).
Lets say that circles are described in matrix as:
circles(1, :) = [x, y, d];
circles(2, :) = [x, y, d];
...and so on
where x, y are coordinates, d is diameter. Now the question is, how to simulate this circles, until given crowding parameter c is reached? c is simply defined as: c = yellow area / square area (in this case A^2).
And the second thing - lets say that everything is simulated and I want to check if some coordinate (x,y) is within or outside yellow area... How to do it? I was doing it by checking if my (x,y) is within area of each circle (but its getting more difficult when instead of circles I use i.e. round shape rectangles), one by one, but there must be some better way of doing it.
Thanks for help : )
Here is an approach that should do the trick:
Start with a large empty matrix (big enough to guarantee that every shape generated is fully inside the matrix). Suppose we do it like this color = zeros(100)
while we have not yet reached the cowding ratio: the midpoint and diameter of one circle, I assume you can manage this
change the color of all points in the circle, for example by setting it to one.
Calculate the crowding ratio (something like c = mean(mean(color))
Note, if you only want to use part of the matrix (enable shapes to fall partially out of the picture) this can for example be achieved by using mean(mean(color(11:end-11)) in step 4, ignoring the 10 pixels near the edge.
Now if you want to know whether point (x,y) is yellow, simply check the value of color(x,y). Or if you want to ignore the edges check color(x+10,y+10)