How to Subtract and Add across columns in Matlab?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Minjun Seo
el 13 de Ag. de 2019
Comentada: Star Strider
el 14 de Ag. de 2019
Okay, I have a data table.
I want to perform simple mathematical operations on the columns of the table versus let's say a different column.
Similar to diff() but diff() works going down the column. I want to know a way to go across.
0 comentarios
Respuesta aceptada
Star Strider
el 14 de Ag. de 2019
Editada: Star Strider
el 14 de Ag. de 2019
In the documentation for diff, see Differences Between Matrix Columns. You need to specify the dimension.
EDIT —
With respect to adding, cumsum (and sum) work the same way. See: Cumulative Sum of Each Row In Matrix.
2 comentarios
Star Strider
el 14 de Ag. de 2019
I thought you were actually working with matrices.
Neither diff nor cumsum will work on tables, even using the rowfun function.
You would need to use the table2array function to extract the data from the table, do the calculations, then create a new table with the results.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!