我只是试图从一个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.
更多推荐
发布评论