Link editable field to a certain cell in table figure in MATLAB app designer - matlab

I am building an application in MATLAB app designer (2019b), and I am trying to link two blank fields to a table that has only two columns, such that the first field should show the first value (in the first column) in the table and the other should show the last value in the first column in the table.
Example
table:
9 2
3 4
5 6
blank field_1: 9
blank field_2: 5
I am a C++ person, so whenever I am developing, for instance in SFML, I just have one event loop that captures and updates everything - no matter where I press on the window, but, in MATLAB, whenever I press a button - I need to build a separate callback function. Here, I am not calling back anything - I just need to update the value.
Anyone, please help?
Thank you

Here's an example which illustrates how you can achieve the behavior you want.
In the below example, I am creating a uitable in the App startup, and I am defining a callback which updates the table as required when the cells are modified.
function startupFcn(app)
vars = {9,2;3,4;5,6;'blank _field_1:', '';'blank field_2:', ''};
t = uitable(app.UIFigure,'Data',vars);
t.ColumnEditable = true;
t.DisplayDataChangedFcn = #updateTable;
function updateTable(src,~)
src.Data(end-1:end,2:end) = [src.Data(1,1) src.Data(end-2,1)].';
end
end

Related

How to display table in parts in command window in matlab?

I have a table which consists of 17025 rows. When I try to display the table, the whole table displays. But I want it in small parts. How do I make it display in small parts.
Type more on at the MATLAB command prompt. Subsequent output will be paused after every screenful.
Documentation: https://www.mathworks.com/help/matlab/ref/more.html
I usually check my variables in these ways:
Suppose that we have a variable called A=rand(1000,1000).
1.we can display a part of A by calling A(127:130,241:243), to show the specific part of it.
>> A(127:130,241:243)
ans =
0.8152 0.0674 0.5609
0.1977 0.3906 0.6491
0.3288 0.1255 0.7478
0.9176 0.4253 0.5111
2.double click the name of the variable in the Workspace, so we could check it in Variables.
3.if your data only contain few columns, I recommend you to draw them in a figure and view them by dragging a Data Cursor in the picture.
SampleCode:
A=[1:1:200; 250:-1:51];
plot(A')
However, only the first option could display matrix on command window, but 2&3 is much faster since we don't know which part to display.

LibreOffice BASIC function - Copy if over a value to a new sheet

I'm trying to create a simple function on a LibreOffice Calc sheet.
I have a table of information where cells A1:K2 has headings (the cells in Row 2 are merged)
all the information runs from A3:K176
The sheet has various functions running on it already, all I need is one more function.
At first I wanted it to automate when i open, but then i thought running the BASIC macro off of a button might be better, so i can edit and then just hit the button once I'm done.
I have the button linked up to run the macro already, but now im stuck... I have tried many ways of writing the code, but it seems that i am just too green to figure it out.
the last time i ran Excel advanced functions i was in high school.
ok, enough talking...
All I need the macro to do is once I hit the button, I need it to check column K and any value > 1 it needs to take that whole row and copy it then go to a target sheet, clear any data on the target sheet. then copy that set of rows to the next open row in the target sheet. possibly even exporting the result to a .txt file as a bonus.
this is a start...
in future I would like to add another button that will do the same function to a array lower down and put that into a different sheet.
Option Compatible
Sub SWD_AwakeningsTrade
Dim i, LastRow
LastRow = Sheets("Card_List").Range("A" & Rows.Count).End(xlUp).Row
Sheets("Awakenings For trade").range("A2:I500").clearContents
For i=2 to LastRow
If Sheets("Card_List").Cells(i,"K").Value = "(>1)" Then
Sheets("Card_List").Cells(i, "K").EntireRow.Copy
Destination:=Sheets("Awakenings For trade").Range("A" & Rows.Count.end(xlUp)
End if
next i
End Sub

Focus handling in SAPUI5

We have a requirement that of using a "tab" key in the table control to navigation across only input fields.
1. Every table row has atleast 6 to 8 fields - 2 of them are input fields and rest could be text,select etc.
2. By clicking tab i navigate across input fields in a row on clicking the last input field of a row i should move to the first input field of the next row.
I have the code for the following but i can see the focus method of the input control focuses the UI to subsequent input field of the input to be focused.
Jsbin - https://jsbin.com/lugesecuhe/edit?html,output
I tried to set styles like .sapMFocus and also document.getElementbyId().focus and they dont work either.
Can you suggest some pointers on this.
Thanks and Regards,
Veera
I have exactly the same problem and started looking into it. I found out that the navigation within the table is possible and performed by class sap.ui.core.delegate.ItemNavigation (at least in v1.26).
However, what I consider really non-intuitive:
On Mac (Chrome or Safari) you have to hold the ALT key while pressing TAB to cycle through the input fields of your table.
I haven't figured out how to do it on Windows
I checked in your JSBin example, somehow the fields get focused in a weird order. I have prepared my own example - http://jsfiddle.net/bgerth/x8h92mz8 - where you can cycle through the input fields row by row using Alt+Tab.
Update 1
I have found the blog SAPUI5 Table Navigation with Tab Key by Klaus Kronawetter which adds extra keyboard handling to a sap.ui.table.Table. I adapted his code for a sap.m.Table which you can find at http://jsfiddle.net/bgerth/os6r096y.
Update 2
After further investigation, I decided that the solution from update 1 above is too much hassle.
Instead, I adapted the class sap.ui.core.delegate.ItemNavigationmentioned above, which is internally employed by sap.m.ListBase. In essence, you can cycle through the input fields with up and down arrow keys.
I have prepared an example at http://jsfiddle.net/bgerth/0r9L30wd. The relevant code is
var fnPatchedItemNavigationsetItemDomRefs = sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs;
sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs = function setItemDomRefsPatched(aItemDomRefs) {
// 'this' is now the instance of sap.ui.core.delegate.ItemNavigation
jQuery.sap.log.debug("Patched version of sap.ui.core.delegate.ItemNavigation.setItemDomRefs");
var aInputFields = $(aItemDomRefs).find("input:enabled").get();
if (aInputFields[0]) {
// There is at least one enabled input field in this table
fnPatchedItemNavigationsetItemDomRefs.call(this, aInputFields);
} else {
fnPatchedItemNavigationsetItemDomRefs.call(this, aItemDomRefs);
}
}

Excel stops working when adding new row to the Table

I don't know why but when I try to do this Excel Quits without saving anything:
On Sheet1 I have 11 Rows x 6 cols formatted as Table. With 1st row as Table Header.
I assign col A as a STU_ID Named Range using Name Manager.
I have only a listbox on the Userform. And I give RowSource property as =STU_ID . I get the col A data on the list box.
Now when I go to Sheet1 and try to add more data on next row of the table. Excel quits saying it has stopped working. Windows is checking for error and it restarts on a blank Workbook.
Shouldn't Listbox be dynamic and get data from Name Manager as I add them on the sheet ?
I am using MS Excel Pro 13 on Win 10 64 bit.
This is a bug in Excel. As a workaround, use the .List property instead of the .RowSource.
Try something like this in the UserForm's code:
Private Sub UserForm_Initialize()
ListBox1.List = Range("table1[abc]").Value
End Sub
This way it will be dynamic, and it will work.
If you need it to change while the userform is displayed, put a small code to the Sheet change event, that updates the list every time the sheet changes. (This is only necessary if your form is modal, and you want it to reflect the changes made in real-time.)

Getting selected cell indices from uitable

I have a uitable with 10 columns, which I'm populating from a db.
Now I want to know when the user choose a specific row. For example if the user chooses the 3rd record, I would like to get back the value 3, so then I could access the actual information to for example open that specific record from the path.
I found online that I would need findjobj.
I also think that the method should be implemented in here:
function uitable_CellSelectionCallback(hObject, eventdata, handles)
However I found a little information about how I should proceed.
Anyone had this problem or knows how to solve it?
When calling the CellSelectionCallback you can access the Indices property, which is a 2 x 1 array containing the row and column indices of the cell you have selected.
Therefore in your callback, use something like this:
row = eventdata.Indices(1)
col = eventdata.Indices(2)
and that should get you going.
In order to avoid callbacks, you can use app.UITable.Selection in the newer versions of MATLAB where app is your app object and UITable your uitable name