简体   繁体   English

Matlab GUI表-索引超出矩阵尺寸

[英]Matlab GUI table - index exceeds matrix dimensions

I have created a Matlab GUI with Matlab's GUIDE tool and am executing some code now. 我已经使用Matlab的GUIDE工具创建了Matlab GUI,现在正在执行一些代码。 As part of the output, I created a table, which I would like to populate with a matrix I calculated previously. 作为输出的一部分,我创建了一个表,我想用之前计算出的矩阵填充该表。 I am continuing to run in the "index exceeds matric dimensions" problem and I don't understand why... 我继续遇到“索引超出矩阵尺寸”的问题,我不明白为什么...

here is what my output matrix looks like that I want to pass in the output table: 这是我想在输出表中传递的输出矩阵:

Final =

                 22518                     21839
     0.539035438316014         0.563853656302944
     0.452748911981526         0.428133156280049
   0.00821564970246025       0.00801318741700627
    -0.452748911981526        -0.428133156280049 

To me, this looks like a 5 x 2 matrix. 对我来说,这看起来像一个5 x 2的矩阵。

Here are the properties of the output table 这是输出表的属性

Table (result) with properties:

            Data: {5x2 cell}
     ColumnWidth: {'auto'  'auto'}
  ColumnEditable: [0 0]
CellEditCallback: ''
        Position: [4.6 23.0769230769231 81.4 11.2307692307692]
           Units: 'characters'

In the property manager, it tells me that it has a Data structure of 5x2 cell array. 在属性管理器中,它告诉我它具有5x2单元数组的数据结构。 The tag of the table is "result". 该表的标签为“结果”。

I now want to use the following code to populate the table: 我现在想使用以下代码填充表:

set(handles.result('Data',Final))

However I keep getting the "index exceedsmatrix dimensions" error. 但是我一直收到“索引超出矩阵尺寸”错误。

If I mannualy insert code to create a UI table it works fine: 如果我手动插入代码来创建UI表,则可以正常工作:

h = uitable('Data', Final);

I noticed however, when I call the properties of this table, the data structure is different in the sense that is says "5x2 double" instead of "5x2 cell". 但是,我注意到,当我调用该表的属性时,数据结构在某种意义上是不同的,即“ 5x2 double”而不是“ 5x2 cell”。 Is this the error? 这是错误吗?

Would very much appreciate if someone could help me out here 如果有人可以在这里帮助我,将不胜感激

Thanks! 谢谢!

Welcome to SO. 欢迎来到SO。 There is a syntax error in your code. 您的代码中存在语法错误。 Instead of: 代替:

set(handles.result('Data',Final))

you should write: 您应该写:

set(handles.result,'Data',Final)

Hope this helps ! 希望这可以帮助 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM