Error:Conversion to cell from logical is not possible.
Afficher commentaires plus anciens
Dear programmers
I want to study a logical algorithm. I have some values in a matrix(n x 3) where the first column is serial number and last 2 columns are variable values and number of rows is "n" . The variables are HP and SS. I want to execute logical statement upon these values under variables HP and SS to get a desired result and store the results for each row in a separate columns say, Column E and Column V . I dont know how to store the values from if else statements in separate column. While executing the below code with "disp" syntax also I am receiving an err message as " Conversion to cell from logical is not possible".
I am sharing the code. Please check and help.
if {(HP==0)&& (SS==0)}
E =1;
V = 0.167;
elseif {(HP > 0.15)||((HP > -0.15 )&& (SS > 0.05))||((HP > -0.15 )&& (SS < -0.05))}
E = 2;
V = 0.167;
elseif {((HP < -0.15) && (SS > 0.15 ))||(( HP < -0.15) && (SS < -0.15 ))}
E = 10;
V = 0.167;
elseif {(HP < -0.15) && (-0.15 < SS < 0.15 )}
E = 1000;
V = 0.3;
elseif {( -0.15 < HP < 0.15) && ( -5 < SS < 5)}
E = 6000;
V = 0.3;
end
9 commentaires
jahanzaib ahmad
le 2 Mai 2019
Modifié(e) : jahanzaib ahmad
le 2 Mai 2019
u are not storing the values u r telling matlab to use the values of E and V if this else that .
u want to add E and V infront of matched values ...i think u can use
for i =1:n
HP=DATA(i,1);
ss=data(i,2);
if (HP==0)&& (SS==0)
E(i,3)=1;
V(i,3) = 0.167;
............................................
madhan ravi
le 2 Mai 2019
"its a table .. so { } should not be used ..."
google " how to access table MATLAB "
RAJ
le 2 Mai 2019
jahanzaib ahmad
le 2 Mai 2019
please upload small part of m .
jahanzaib ahmad
le 2 Mai 2019
Modifié(e) : jahanzaib ahmad
le 2 Mai 2019
HP=m(i,1);
SS=m(i,2);
m(i,3) =1;
m(i,4) = 0.167;
.
put them infront of m ..or if u want to make a new variable ..its the same
jahanzaib ahmad
le 2 Mai 2019
whats the error now ,? same ?
madhan ravi
le 2 Mai 2019
@Ahmad: Why did you delete the comment which I was referring to?
jahanzaib ahmad
le 2 Mai 2019
Modifié(e) : jahanzaib ahmad
le 2 Mai 2019
i thought i made a mistake .. i never used tables .
"its a table .. so { } should not be used ..."
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!