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

1 次查看(过去 30 天)
Dear all,
I have code for creating FEM model, but there is an error :
Undefined function 'sum' for input arguments of type 'cell'.
Error in mean (line 115)
y = sum(x, dim, flag)/size(x,dim);
Error in ng_mk_extruded_model>calc_centroid (line 415)
m = mean(points);
Error in ng_mk_extruded_model>parse_shape (line 231)
tank_shape.centroid = calc_centroid(points);
Error in ng_mk_extruded_model>mk_extruded_model (line 91)
[tank_height, tank_shape, tank_maxh, is2D] = parse_shape(shape);
Error in ng_mk_extruded_model (line 76)
fmdl = mk_extruded_model( shape, elec_pos, elec_shape, extra_ng_code );
Error in Newmodel (line 41)
fmdl = ng_mk_extruded_model(thorax_shape, elec_pos, elec_shape);
Error in DP_segment_final>Okoli_Callback (line 418)
[fmdl,img_okoli] = Newmodel(params,shape);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in DP_segment_final (line 44)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DP_segment_final('Okoli_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
I attach my codes and original image. Thank you for your answers.
  6 个评论
Walter Roberson
Walter Roberson 2017-3-14
One of the first htings that DP_segment_final does is prompt for the location of eidors. However, it then ignores the answer, and instead has hard-coded a number of references to editors at one particular location in C:/ . That's a bit of a problem for non-PCs.

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2017-3-13
I'd start with using the debugger. Type this in the command window:
dbstop if error
(Or use the corresponding menu element in the editor) and run your code again. Then Matlab stops at the error and you can check the types of the variables in the Workspace Browser or in the command window:
class(x)
class(dim)
class(flag)
Now search in the code, where the variable, which is a cell, has been defined. The error message is clear: sum() cannot operate on cells, therefore the command, which created this variable as a cell is the problem.
  2 个评论
Veronika
Veronika 2017-3-13
It doesn´t help, because these variables are in Matlab in .m file mean.m. So I think, that Command Window doesn´t help me...
Jan
Jan 2017-3-13
编辑:Jan 2017-3-13
@Veronika: Please, try it. The dbstop command triggers the debugger to stop Matlab, when the error occurres. Then you can inspect the current workspace. Of course this does not solve the problem, but it will help to recognize, what the problem is.
It would be easier, if you run this and post the reply of the shown command, than to let the readers download the files and do this on their computers. In addition you would learn how to use the debugger to examine the sources of errors.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Read, Write, and Modify Image 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by