Doing calculation across columns
Mostrar comentarios más antiguos
Hi there. I have a 4 column by 500 row matrix. How would I add a fifth column that calculates
, where x is the corresponding value in the second column across the same row.
Thanks!
Respuesta aceptada
Más respuestas (1)
JULIEN BARBAUD
el 22 de Abr. de 2019
Editada: JULIEN BARBAUD
el 22 de Abr. de 2019
I think that if you call your input matrix A, and the final result B, then this:
f=@(x) exp( (-(x-75)/2).^2 )
B=[A f(A(:,2))];
should do the trick
EDIT: oops, madhan was quicker
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!