calculation within a matrix

Consider a matrix with 1877958 rows and 7 columns. How can I subtract the first row, second row, third row... in column 1 from the first row, second row, third row, fourth row..... in column 7 and then divide the result by the first row, second row, third row, fourth row.... of column 3 until all 1877958 rows are covered. I want the result to be displayed as a 8th column.

 Respuesta aceptada

Geoff Hayes
Geoff Hayes el 26 de Nov. de 2014

1 voto

AA - if A is your matrix, then the calculation that you wish to perform could be written as
B = (A(:,7) - A(:,1))./A(:,3);
Then just append B as your 8th column of A as
A = [A B];
Try the above and see what happens!

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

AA
el 26 de Nov. de 2014

Respondida:

el 26 de Nov. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by