问题标签 [matlab-uitable]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
333 浏览

matlab-figure - 在 Matlab 的命令窗口中显示 Uitable 数据

我正在使用 UITABLE 来显示一些数据。显示表格后,我想在命令窗口中以矩阵形式获取数据进行计算并再次以表格形式显示结果。任何1请。帮我..

0 投票
2 回答
4879 浏览

matlab - Programmatically save changes of an editable uitable

I created an UItable in Matlab which I fill with various values and options. It looks like:

enter image description here

the corresponding code is the following:

So I run the code and the figure is open. The underlying script has therefore finished. When I now edit the table my uitable object is changed and after I finished I can get my final configuration with:

But the thing is I need manually type this line, because my script has already finished. If I put this line at the end of my script, I get an error.

So I thought about using the following loop, to detect when I close the table and to store the last configuration

And I tried everything to put inside the loop, the whole script, just the set command including the celleditcallback, and other things, but nothing worked. Either my script get stucked inside the loop or the display of my table is not updated when I edit a value. I also tried drawnow at different positions. How one handles this situation? How can I automatically store my final results? I assume "closing the window" is the best action to detect, as I don't think I could implement a "save" button. I also tried to create a gui using GUIDE but got completely lost, I hope to solve it without.


Edit: I was now able to implement a "save"-button and tried the callback as follows:

also I implemented a custom CloseRequestFcn as suggested by Lucius Domitius Ahenobarbus. But then I have either one of the following problems:

1) I define everything as a script, everything works fine, but I need to define functions like @saveConfig (actually my favorite) or @my_Closefcn as a unique function-file in my workspace and I have a hard time to pass the right parameters as dat always remains the same, even though it actually gets changend. (The example from the mathworks site works! But it doesn't need additional parameters.)

2) When I use

I can implement @saveConfig or @my_Closefcn directly (nested) and I guess the passing of the parameters would work fine. But the editing of my table does not work anymore, throwing the following error:

Error using handle.handle/get

Invalid or deleted object.

Error while evaluating uitable CellEditCallback

How to solve that? Now that I know that I can even add buttons to an uitable I REALLY like to avoid GUIDE. My code above is executable, so I'd be glad if you try it to see what my actual problem is, as it is hard to describe.

0 投票
3 回答
2670 浏览

matlab - 是否可以防止弹出一个合适的弹出菜单?或者:如何通过单击单元格来获取回调,返回行和列索引?

对于用户界面,我正在编写一个uitable. 用户在第一列中选​​择选项A、B 或 C,第二列中的子选项取决于第一列中选​​择的内容,A.1,A.2 或 A.3B.1,B.2或 B.3C相同

在此处输入图像描述

该表的代码可在附录 A中找到。

当用户首先定义主选项时,子选项会自动相应地减少为只有有效的选项。这是通过评估CellEditCallbackfor column 1并重置ColumnFormatfor column 2来实现的。(附录BmodifySelection中的功能)如果用户现在意识到他犯了一个错误并且需要再次编辑一个子选项,那么仍然根据之前编辑的设置主选项和有效选项不可用,除非他再次重新选择主选项。(请参见图片中的蓝色突出显示)。ColumnFormat

为了解决这个问题,我还实现了CellSelectionCallback调用函数justifySelection(在附录 B中),该函数通过选择进行检查,在第 1 列中选择了哪个选项以再次为第 2 列提供正确的子选项。但是当这个回调对选择做出反应时,我需要选择两次,一次触发CellSelectionCallback,另一次实际得到我的选择。对于大桌子,这可能很烦人!

所以我的问题是:

有没有办法阻止第 2 列中的弹出菜单弹出,直到它发现相应第 1 列的内容是什么,所以它立即提供有效的选择?

或者:

如何检测鼠标单击单元格并获取行和列索引?但是没有调用以下选择并弹出操作?

我已经在搜索所有可用的属性,但没有找到任何有用的东西。也许可以使用 做某事ButtonDownFcn,但如何获取单元格索引?财产呢BusyAction,如何用于我的目的?

有任何想法吗?

我很抱歉提前用这么多代码轰炸你,它已经是最小的例子,但完全可执行,所以你可以尝试一下。


附录 A/B


最后是modifyPopup重写的单个函数Columnformat

赏金:为什么只是+50?- 我想这是不可能的,或者答案很简单,一旦一个人有了正确的初步想法。我不是在寻找使用 java 对象属性等的复杂解决方法。提前谢谢你!


我在此处包含评论中的讨论以保持概述:

如果您想尝试一下,可以复制代码并按照以下步骤重现不良行为:

  1. 在第一行中选择主要选项 A。
  2. 第一行中的子选项则包含选项 A.1、A.2 和 A.3。
  3. 选择第二行的主选项B,因此第二行的子选项的选择是B.1、B.2和B.3
  4. 但是现在您想(直接)更改第一行中的子选项;你会期望得到选项 A.1、A.2 和 A.3;但你没有。您将获得 B.1、B.2 和 B.3;- 因为您选择的最后一个主要选项是 B(尽管在不同的行中)。

看来,您应该查看相关选项,而不是寻找最后一个选项。因此,要么确保单击子选项进行“查找”以查看存在哪个主选项,

这正是我正在寻找的!但我怎么能这样做呢?如何检测点击,获取列&行索引,设置正确 ColumnFormat,最后让单元格弹出。到目前为止,我看到的唯一可能性是CellSelectionCallback,但它是在单元格已经弹出无效选项后执行的。我需要一种ClickedCallback,就像有pushbuttons

或确保选择主选项仅设置该行的子选项。

这是不可能的,您不能根据需要为某行设置子选项 modify ColumnFormat,这会影响整个表而不仅仅是一行。

0 投票
2 回答
943 浏览

matlab - uimenu 按钮保持按下状态,只需在其他菜单上滑动即可触发其他菜单:所需的按钮行为

我在我的中实现了各种uimenus,uitable但出现了一个非常烦人的行为。

但是在执行回调函数之后,菜单按钮仍然被按下并突出显示,甚至没有,当我滑过下一个菜单按钮时,这个也被触发了!

Matlab Central 也描述了这种行为,但没有解决方案。

我尝试了建议:

这不会改变任何东西。set(gcbo,'Enable','off')单独可以解决滑动问题,但也会禁用整个按钮,这是我不想要的。我还尝试使用“Checked”、“Visible”和“Interuptible”属性,但没有成功。这个问题一定要知道,有什么提示吗?

我还考虑过使用uicontrol而不是uimenu使用按钮,但我没有得到它的工作。


编辑:当我将菜单按钮放入子菜单时,它可以完美运行:


Edit2:Apushbutton也可以,但我怎么能把它放到菜单栏中呢?

0 投票
1 回答
2178 浏览

matlab - 未选中 MATLAB 合适的逻辑复选框

我在 MATLAB R2012b 中使用 GUIDE,并且有一个uitable可编辑的逻辑复选框。单元格编辑回调如下:

当我单击其中一个复选框时,我可以看到表中的数据得到了适当的更新(两者都get(hObject,'Data')返回handles.checked(row)了更新的值),但是 GUI 中的实际复选框并未在视觉上被选中。如果我再次单击它,变量将再次更新,但复选框保持未选中状态。

所以数据正在更新,但 GUI 没有。这里出了什么问题?

注意:逻辑复选框在 GUIDE 中设置为可编辑,所以这不是问题。

0 投票
2 回答
6597 浏览

matlab - How to deselect cells in uitable / how to disable cell selection highlighting?

I created the following uitable:

bug

actually every single row is an indpendent uitable, so the figure shown contains 5 uitables besides the header. Why I'm doing that was the issue of my last question, resulting in the shown table. Fully executable code you can find in the answer here (or a minimal example below). Solutions using a general GUI are also there, but it would blow up the code too much, and actually it just seems to be a kind of bug.

It can be seen that everytime I jump to the next row, therefore to another uitable, the last selection remains highlighted, which looks stupid, though it doesn't matter for the functionality.

There is the 'SelectionHighlight' property for uitables, sounds like a solution, but it is not changing anything. I used it as following:

at various places: at the end of a 'CellSelectionCallback', at the end of a 'CellEditCallback' and as global property. But everytime the last cell remains selected. Actually I don't need selection at all.

How can I disable the whole selection or selection highlighting property for all my uitables?

How do I have to use this property, that it has an effect?

Alternatively: how can I change the "highlighting" color (and therefore text-color) so the highlighting is just not visible anymore?

Apparently this issue appears also in other contexts.


I created a minimum executable example, where one can select a number between 1 and 3 in every row.

results in:

min_example

0 投票
2 回答
1927 浏览

matlab - 只能在双击时编辑的表格单元格

只需单击即可编辑表格单元格,我希望仅在双击时对其进行编辑。只需单击即可选择单元格。

我正在使用以下属性uitable

0 投票
2 回答
4225 浏览

matlab - 如何删除uitable中的选定行?

我想删除 uitable 的选定行。我考虑过为每一行使用一个复选框来选择我要删除的那个。

但是我不能将复选框设置为 false 的列添加到表中。

我得到这个跟随错误

我试过这个:

然后我需要从表中删除所有带有选中复选框的行。我怎样才能做到这一点?

0 投票
1 回答
424 浏览

matlab - Matlab将子表中的选定行数据添加到父表

我在我的第一个图形 GUI1 中有一个表格和一个按钮,它将打开一个带有表格 GUI2 的新窗口。在 matalab 中,如何在表 GUI1 中添加表 2 中所选行的行数据。

我首先尝试使用 tihis 方法选择行号:

为了

在两个窗口之间共享数据,但我不知道如何正确使用它:

0 投票
1 回答
1759 浏览

matlab - 在matlab中使用弹出菜单

我创建了一个由四列组成的 uitable。

我现在想要做的是,当代码运行时,我在第一个单元格的弹出窗口中选择'Sweet',单元格(1,4)显示dat(1,1),或者当我选择' Beautiful' 在第一列的第二个单元格中,单元格 (2,4) 显示 dat(2,1)。与 uitable 外部的弹出菜单不同,我无法使用 get(popup,"value')。

我怎么可能做我想做的事?提前致谢!