Setting different Cell-Formats in a Matlab uitable - matlab

I am looking for a way to handle different type of data in one column of a Matlab uitable.
Usually uitable is used to set whole columns to the same data type, such as logical (gives a checkboxes), char (gives left-aligned text), numeric (gives right-aligned number) or a 1xn-cell-array (gives pop-up menus with different choices).
It is set using the columnformat property of uitable, e.g.
columnformat = {'numeric', 'logical', {'Fixed' 'Adjustable'}}; % 3 columns
You can find an example at matlab documentation.
I am looking for a way to set the format for single cells to realize something like this:

Matlab's uitable is a crippled version of an underlying JIDE table.
It is possible to get to the underlying java (see findjobj in file exchange), but that requires a lot of work. Yair Altman's undocumented matlab site is a good starting place for understanding the java side of matlab.
It sounds like you want something like a property editor, as opposed to a generic UI table -- i.e. properties listed in first column, property value editable in second column. There are a few "off the shelf" versions in the file exchange, which use JIDE:
See propertiesgui, or property-grid for mostly functional examples. The second example is easier to use -- you simply provide a class or struct, and it creates the proper field entry format. The first one offers more choices -- like color boxes, drop downs, etc, but requires you to be more involved in specifying how things behave.

I had the same problem, but in the end it worked by giving the (numeric) cell an (char) initial value. When changing the char value from the UI the format of the cell remained char, although the rest of the column was numeric.

Related

How do I set the length of an attribute on a class diagram in EA?

I have a class diagram and have defined an element on this diagram, and created a custom code engineering datatypes type, which allows a fixed width field, for which I want to define a length.
I just can't see where to enter it. The attributes window shows Name, Type, Scope, Stereotype, Alias and Initial Value but doesn't seem to allow anywhere to set the length or precision values.
I want to be able to use this in the report template Att.Length.
I'm sure I've done this before in an earlier version but I can't find where to set this on EA 14.
I'm sure I'm missing something obvious, but I've looked in every properties window I can find.
Thanks for looking! :-)
Length is typically not used with code engineering datatypes, but with database datatypes.
In that case this is intended to be used in database models, and EA will present a different GUI that enables you to edit the length of the datatype.
Technically these field are stored in t_attribute.Length in case of a type such as char, or t_attribute.Precision and t_attribute.Scale in case of a type such as numeric.
There is no (easy) way to fill in these field for regular (non «column») attributes.

Progress 4GL display to a variable

I'm working with a codebase that has multiple display statements. So that all of the outputs line up, the various column numbers are also typed multiple times.
I would like to just use a variable for the column instead of searching for the line and then updating the column width. Something like:
def var i as int init 10.
disp "FOO" to i
"BAR" to i + 5.
If I understand it correctly, you either want to have your frame defined dynamically and at the end so you can assess what the max size for that column is, or you want to define a static frame beforehand, it usually makes it respect the positions (but you won't be able to change it).
Now I was a little thrown off by your code because it has nothing to do with setting the column widths, looks like you're trying to write something different if you're on a specific part of the page. So you might want to look into a few printing functions such as FRAME-DOWN and FRAME-LINE.

How do I change the Fontweight of Table Titles in MATLAB?

Upon creating a table, the 'VariablesNames' at the top of each column are automatically bolded. When I check the table in my diary file, each of the column names are surrounded by HTML style strong tags. Is there a line of code I can use to prevent the automatic bolding?
I've had no luck with the MATLAB documentation for fontweights in regards to table titles: https://www.mathworks.com/help/matlab/ref/matlab.ui.control.table-properties.html They mention font weights, but they don't provide an example of how to implement the code. (The strike-through text wasn't relevant documentation for console outputs.)
Here is the command I'm using to create a table: X = array2table(B,'VariableNames', {'y','One','Two','Three'}); The column titles come out bold, for some reason. Worth noting that B is a 5x4 matrix.
I believe that you are mixing things up: the documentation page that you referenced refers to tables displayed in Matlab GUI (using the uitable function), and its FontWeight property refers to the font-weight of the internal data elements displayed in that table.
This is apparently entirely unrelated to what you're actually doing, which is to use a non-GUI data table, such as one that is created using the table function. Such a table is an object which uses an internal overload of the disp function in order to display the table contents in the Matlab console (Command Window). This overloaded disp function displays the table headers using the HTML <Strong> tag. You can see the full source code in matlabroot/toolbox/matlab/datatypes/#tabular/disp.m, and the part that adds the strong tag around line 45.
In short, if you want table output not to use a strong tag in its header, you need to either modify that file, or create your own class that inherits the table tablular class and overloads the disp function in whatever way that you wish.
Addendum: I just discovered an even simpler way:
feature('HotLinks',0); % temporarily disable bolded headers (matlab.internal.display.isHot=false)
disp(myTable)
feature('HotLinks',1); % restore the standard behavior (matlab.internal.display.isHot=true)
In short, if you want table output not to use a strong tag in its
header, you need to either modify that file, or create your own class
that inherits the table class and overloads the disp function in
whatever way that you wish.
Unfortunately the table class is sealed, therefore a subclass cannot inherit from it.
Error using unbold_table
Class 'table' is Sealed and may not be used as a superclass.
You could always go into the source code as Yair suggested and edit it.
As #YairAltman mentions, the bolding is done by the disp method of the table class.
(Actually, that's not quite true: in older versions, it's done by the disp method of the table class, in the more recent versions, it's done by the disp method of the tabular superclass of the table class).
Yair suggests two ideas:
Firstly, that you might be able to create your own class that inherits from table, and implement your own version of disp. Unfortunately, that won't work as table is Sealed, so you can't inherit from it. (Of course, if you're comfortable with modifying the MATLAB source code you could unseal it; but I don't recommend trying that, they've sealed it for very good reasons).
Secondly, that you might be able to modify the source code for the disp method so that it doesn't do the bolding. That would work, but you might not want to fiddle around with the MATLAB source code (and some may have it installed by IT in a way that is read-only anyway).
However, there is a little undocumented feature of the disp method of table/tabular, that may help you here without modifying anything: if you pass in an additional argument to disp, you can turn off the bold.
>> a = table(1,2);
>> disp(a) % the following Var1 and Var2 are bold
Var1 Var2
____ ____
1 2
>> disp(a,false) % the following Var1 and Var2 are not bold
Var1 Var2
____ ____
1 2
The default value for the second argument is true, so to achieve this you need to call disp explicitly with the second argument false.

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.

LibreOffice, Using Constants as query Parameters

I'm using the VLOOKUP function to move data from one table into another. I need to apply this formula to an entire column, and I need to know how to define certain parameters as variable and some as constant.
Here's my problem:
=VLOOKUP($D8,Sheet2.A1:B20,2)
becomes, when I drag the corner of the cell across multiple rows,
=VLOOKUP($D8,Sheet2.A1:B20,2)
=VLOOKUP($D9,Sheet2.A2:B21,2)
=VLOOKUP($D10,Sheet2.A3:B22,2)
=VLOOKUP($D11,Sheet2.A4:B23,2)
And what I need is
=VLOOKUP($D8,Sheet2.A1:B20,2)
=VLOOKUP($D9,Sheet2.A1:B20,2)
=VLOOKUP($D10,Sheet2.A1:B20,2)
=VLOOKUP($D11,Sheet2.A1:B20,2)
With the first parameter changing and the rest remaining constant. I'm sure there is an easy way to do this, but searching and browsing help topics is returning nothing. I admittedly have zero background in spreadsheets. Thanks for your help
Add more $ signs, like this:
=VLOOKUP($D8,Sheet2.$A$1:$B$20,2)
https://help.libreoffice.org/Calc/Addresses_and_References,_Absolute_and_Relative