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; endelseif 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
Best Answer