Filter löschen
Filter löschen

Error:Conversion to cell from double is not possible.

7 Ansichten (letzte 30 Tage)
RAJ
RAJ am 22 Aug. 2019
Kommentiert: RAJ am 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.
Please help !
N.B: I have attached the txt file for reference.
fID = fopen('no_header.txt','r');
stress=textscan(fID,'%n %n %n','headerlines',7,'Delimiter','');
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

Akzeptierte Antwort

Divya Tejaswini
Divya Tejaswini am 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 Kommentar
RAJ
RAJ am 30 Aug. 2019
Thanks Divya .. It was a silly mistake on my part..Thanks a lot

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Decomposition finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by