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
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
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 件のコメント
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 Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!