how to add specific columns in table (in verse)

4 visualizaciones (últimos 30 días)
Daniel Cisek
Daniel Cisek el 7 de Dic. de 2022
Editada: Stephen23 el 7 de Dic. de 2022
I have a table T1 in cell that looks like this (values are double):
T1 =
Ligota1 Ligota2 Orzesze1 Orzesze2 Tychy1 Tychy2
_______ _______ ________ ________ _________ _________
1 2 3 4 5 6
7 8 9 1 2 3
4 5 6 7 8 9
0 1 2 3 4 5
6 7 8 9 0 10
How to add table rows omitting specific columns e.g. names begining with 'Ligota'. I tried to do it with varfun and rowfun functions with no luck. I was able to sum only the rows of all columns:

Respuesta aceptada

Jiri Hajek
Jiri Hajek el 7 de Dic. de 2022
you've righly spotted the subtle difference parentheses vs curly braces ("Curly braces, {}, returns an array concatenated from the contents of selected rows and variables.", see here). So it is sufficient to tell the summation operator, which columns to sum (let's say 2nd and 4th):
  4 comentarios
Daniel Cisek
Daniel Cisek el 7 de Dic. de 2022
Thanks Stephen23. I always try to compress code as much as possible. Maybe it's time to think about how to write it transparently.

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre Matrices and Arrays 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