if" function in matrix elements

1 visualización (últimos 30 días)
Jagadesh Rao
Jagadesh Rao el 2 de Nov. de 2014
Comentada: Jagadesh Rao el 2 de Nov. de 2014
please help, i got quesion of matrix and if condition.
If G=any matrix with two columns.
if one of the numbers in G is equal or less than 1,
C=A+B
elseif if two of the numbers in G is equal or less than 1,
C=A-B.
How to create this condition?
please help. any help will be appreciated.
Thanks Jagadesh Rao Thalur

Respuesta aceptada

Roger Stafford
Roger Stafford el 2 de Nov. de 2014
s = sum(G(:)<=1);
if s == 1
C = A+B
elseif s == 2
C = A-B
else
??? What do you want to happen if either none or else more than two have this property?
end
  1 comentario
Jagadesh Rao
Jagadesh Rao el 2 de Nov. de 2014
Thankyou so much. Roger Stafford
i'll fill the else in the end.
see you again.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by