# Error:Conversion to cell from double is not possible.

69 views (last 30 days)
RAJ on 22 Aug 2019
Commented: RAJ on 30 Aug 2019
Dear Programmers
I have a below written code in which I want to run a logical algorithm based on parameters HP and SS with if-else. YM is another parameter which will store the results of the logical statements. HP and SS are 2 cell-array columns which are derived from stress array. YM is another cell-array columns derived a matrix E. "for" loop is executed from row 1 to last row of the stress array so that the values of HP and SS can be evaluated in each row to give a desired value of YM in the YM cell-array following the logical statements.
While executing the code I am receiving the error message: Conversion to cell from double is not possible.
N.B: I have attached the txt file for reference.
fclose(fID);
E = zeros(size(stress{1,1}));
YM= num2cell(E);
HP= num2cell(stress{1,2});
SS= num2cell(stress{1,3});
for i= 1:size(stress{1,1},1)
if HP{i}==0 & SS{i}==0
YM(i,1) =1;
elseif HP{i} > 0.15 & SS{i}==0
YM(i,1) = 2;
elseif HP{i} > -0.15 & SS{i} > 5
YM(i,1) = 2;
elseif HP{i} > -0.15 & SS{i} < -5
YM(i,1) = 2;
elseif HP{i} < -0.15
if SS{i} < -15 | SS{i} > 15
YM(i,1) = 10;
else
YM(i,1) = 1000;
end
elseif HP{i} > -0.15 & HP{i} < 0.15 & SS{i} > -5 & SS{i} < 5
YM(i,1) = 6000;
else
warning('CURRENT VALUES OF HP AND SS NOT COVERED BY THIS SIMULATION')
end
end

Divya Tejaswini on 23 Aug 2019
Since YM is cell, you need use curly braces { } for indexing to access the contents of cells. YM(i,1) in lines 10, 12, .. 24 has to be replaced to YM{i,1}

#### 1 Comment

RAJ on 30 Aug 2019
Thanks Divya .. It was a silly mistake on my part..Thanks a lot