Respuesta aceptada

Jim Riggs
Jim Riggs el 28 de Feb. de 2018

2 votos

the statement
sum(A(1))
is summing only the first element in A, which is 1.
If you want to sum the first row, it should be
sum(A(1,:))
and if you want to sum the first column, it is
sum (A(:,1))

3 comentarios

ahmad qadan
ahmad qadan el 28 de Feb. de 2018
thx but the first element is 1 ,, 1+1 = 2 i cant understand it
Jim Riggs
Jim Riggs el 28 de Feb. de 2018
The matrix A is:
1 3 2 6
5 7 7 0
-2 6 -2 1
The first element in A is A(1) which is 1. So the statement
sum(A(1))
is the same as
sum(1)
and has a value of 1.
ahmad qadan
ahmad qadan el 28 de Feb. de 2018
oooohhh ok thx a lot

Iniciar sesión para comentar.

Más respuestas (1)

elham kreem
elham kreem el 28 de Feb. de 2018

1 voto

WHAT are you want? IF YOU want to sum all the values then use Sum (A) BUt you sum the first element only. IF you help this answer then except to it.

1 comentario

ahmad qadan
ahmad qadan el 28 de Feb. de 2018
why j = 1 ,, if the sum first element 1+1 = 2

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 28 de Feb. de 2018

Comentada:

el 28 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by