首页 > 解决方案 > MATLAB 编辑字段不接受打印值

问题描述

我尝试分配时显示错误...

app.WBCCount = app.WBC_Count;

错误是...

设置类“zia”的属性“WBCCount”时出错:无法将双精度值 76 转换为句柄

当我按下一个名为“countWBCButton”的按钮时,将调用一个函数。这是发生错误的功能...

% Button pushed function: CountWBCButton
    function CountWBCButtonPushed(app, event)

        if app.c ==1
            app.WBCCount = app.WBC_Count;  %Error Error Error Error.....
        else
            msgbox('First segment WBC','Error' , 'error');
        end
    end

错误显示在上述函数中标记为错误的注释行

白细胞计数

WBCCount 是公共属性。 它的属性如下图所示。

标签: matlabvariable-assignmenthandle

解决方案


错误是不言自明的:WBCCount是一个句柄app.WBC_Count是一个双精度

您正在尝试将 double 的值直接放置到WBCCount,而不是设置 的相关属性WBCCount

如果app.WBCCount是类matlab.ui.control.NumericEditField使用:

app.WBCCount.Value = app.WBC_Count;

推荐阅读