使用utable,matlab的数据时出错(Error working with data of a uitable, matlab)

编程入门 行业动态 更新时间:2024-10-25 16:21:26
使用utable,matlab的数据时出错(Error working with data of a uitable, matlab)

我只是试图从一个uitable(用GUIDE制作)获得一些用户输入,并将这个输入保存为双精度来计算另一个值并加上uitable所以这里是代码...

% --- Executes on button press in CTE. function CTE_Callback(hObject, eventdata, handles) % hObject handle to CTE (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) DATA = get(handles.uitable2,'data'); for I = 1:5 s = DATA(1,I); d = DATA(2,I); u = DATA(3,I); p = DATA(4,I); t = DATA(5,I); r = DATA(6,I); c = DATA(7,I); a = DATA(8,I); if ((2 * s * d * u) > 0) && (((t + r) * c) + (2 * a * (1 - (u / p))) ~= 0) X = ((2 * s * d * u) ^ (1 / 2)) / ((((t + r) * c) + 2 * a * (1 - (u / p))) ^ (1 / 2)); else disp('error,ingrese unicamente numeros positivos'); end DATA(9,I) = X; end set(handles.uitable2, 'data', DATA);

但是我收到了这个错误......

对于'cell'类型的输入参数,未定义的函数'mtimes'。

Error in GuiFinal>CTE_Callback (line 133) if ((2 * s * d * u) > 0) && (((t + r) * c) + (2 * a * (1 - (u / p))) ~= 0)

对于发生的事情一无所知,我只是看不出有什么不对

I'm just trying to get some user inputs from an uitable (made with GUIDE), and save this inputs as doubles to calculate another value and put on the uitable So here is the code...

% --- Executes on button press in CTE. function CTE_Callback(hObject, eventdata, handles) % hObject handle to CTE (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) DATA = get(handles.uitable2,'data'); for I = 1:5 s = DATA(1,I); d = DATA(2,I); u = DATA(3,I); p = DATA(4,I); t = DATA(5,I); r = DATA(6,I); c = DATA(7,I); a = DATA(8,I); if ((2 * s * d * u) > 0) && (((t + r) * c) + (2 * a * (1 - (u / p))) ~= 0) X = ((2 * s * d * u) ^ (1 / 2)) / ((((t + r) * c) + 2 * a * (1 - (u / p))) ^ (1 / 2)); else disp('error,ingrese unicamente numeros positivos'); end DATA(9,I) = X; end set(handles.uitable2, 'data', DATA);

but I'm getting this error...

Undefined function 'mtimes' for input arguments of type 'cell'.

Error in GuiFinal>CTE_Callback (line 133) if ((2 * s * d * u) > 0) && (((t + r) * c) + (2 * a * (1 - (u / p))) ~= 0)

Any idea of what is happening, I just don't see what's wrong

最满意答案

看起来DATA是一个单元阵列。 您可能需要使用花括号对其进行索引:

s = DATA{1,I}; d = DATA{2,I}; u = DATA{3,I}; p = DATA{4,I}; t = DATA{5,I}; r = DATA{6,I}; c = DATA{7,I}; a = DATA{8,I};

然后是:

DATA{9,I} = X;

在功能结束时,我会这样做

guidata(hObject,handles)

有关更多详细信息,请参阅有关单元阵列中的访问数据的文档以及存储或检索GUI数据 。

It looks like DATA is a cell array. You probably need to index it with curly braces:

s = DATA{1,I}; d = DATA{2,I}; u = DATA{3,I}; p = DATA{4,I}; t = DATA{5,I}; r = DATA{6,I}; c = DATA{7,I}; a = DATA{8,I};

and then later on:

DATA{9,I} = X;

and at the end of the function, I would do

guidata(hObject,handles)

For more details, see the doc on Access Data in a Cell Array and Store or retrieve GUI data.

更多推荐

本文发布于:2023-08-06 04:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1444830.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据   matlab   utable   Error   uitable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!