Making a new variable

10 visualizaciones (últimos 30 días)
LacAnthony
LacAnthony el 2 de Oct. de 2019
Comentada: LacAnthony el 2 de Oct. de 2019

Hello, I would like to make a new variable from existing variables. What I want to do is sum up the first column of 3 variables that I have already made and make 1 new variable with the sums in a 1x3 row.

Respuesta aceptada

David Hill
David Hill el 2 de Oct. de 2019
newVar=[sum(first(:,1),sum(second(:,1),sum(third(:,1)];
  1 comentario
LacAnthony
LacAnthony el 2 de Oct. de 2019
Thank you so much!!

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 2 de Oct. de 2019
new_variable = [sum(first_variable(:,1)), sum(second_variable(:,1)), sum(third_variable(:,1))];
There is another approach that is slightly more compact but requires that the variables be the same size; the above code does not require that.

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by