Undefined operator '/' for input arguments of type 'cell'.

Dear all,
I have this line of code:
Contours{1}={gsubtract(shape.thorax(1:end-1,:),params.Norm)/params.Norm};
And still this error message: Undefined operator '/' for input arguments of type 'cell'.
I figured out how solve operator '-' (by gsubtract), but I don´t know how I solve operator '/'.
This is my whole code:
function [fmdl,img_okoli] = Newmodel(params,shape)
Contours{1}={gsubtract(shape.thorax(1:end-1,:),params.Norm)/params.Norm};
cnt=2;
if exits(shape.leftLung)
Contours{cnt}={(shape.leftLung(1:end-1,:)-params.Norm)/params.Norm};
cnt = cnt + 1;
end
cnt=2;
if exits(shape.rightLung)
Contours{cnt}={(shape.rightLung(1:end-1,:)-params.Norm)/params.Norm};
cnt = cnt + 1;
end
thorax_shape = {params.Height, % výška
Contours, % kontury
1, % použití defaultních vrcholů
params.Refi}; % maxh (zjemnění )
elec_pos = [ params.NumEl , % počet elektrod
params.DistEl, % vzdálenost mezi elektrodami
0.5]'; % v z rovině
elec_shape = [params.RadEl, % poloměr
params.ShapeEl, % kulaté elektrody
params.RefiEl]'; % maxh (zjemnění)
fmdl = ng_mk_extruded_model(thorax_shape, elec_pos, elec_shape);
img_okoli=mk_image(fmdl,1);
end
Can you advise me? Thank you for your answers.

 Accepted Answer

division or / is not defined for cell datatype. So make the numerator and denominator to matrix types[using cell2mat].

4 Comments

Okay, I used cell2mat, but something is still wrong. This is the error message:
Cell contents reference from a non-cell array object.
Error in Newmodel (line 3)
Contours{1}={gsubtract(shape.thorax(1:end-1,:),cell2mat(params.Norm))/cell2mat(params.Norm)};
THis is the line of my code:
function [fmdl,img_okoli] = Newmodel(params,shape)
Contours{1}={gsubtract(shape.thorax(1:end-1,:),cell2mat(params.Norm))/cell2mat(params.Norm)};
Where is problem?
Put these lines in before it crashes and tell us what it shows in the command window:
whos params.Norm
celldisp(params.Norm);
Command window:
Error using celldisp (line 14)
Must be a cell array.
Error in Newmodel (line 3)
celldisp(params.Norm);
It is probably the shape.thorax(1:end-1,:) that is the cell array.

Sign in to comment.

More Answers (0)

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Asked:

on 10 Mar 2017

Commented:

on 10 Mar 2017

Community Treasure Hunt

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

Start Hunting!