Borrar filtros
Borrar filtros

Doing calculation across columns

12 visualizaciones (últimos 30 días)
Nick DeMarchis
Nick DeMarchis el 22 de Abr. de 2019
Comentada: Jenny Hall el 22 de Oct. de 2020
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

madhan ravi
madhan ravi el 22 de Abr. de 2019
D=zeros(500,5);
D=matrix;
D(:,5)=exp((-(matrix(:,2)-75)/2).^2)
  3 comentarios
Stephen23
Stephen23 el 22 de Oct. de 2020
Editada: Stephen23 el 22 de Oct. de 2020
x(:,2) = (((6.64e-34)*(9.5e+9))./((9.274e-24)*(x(:,1)/10000)))
% ^^ you might want array division here
Jenny Hall
Jenny Hall el 22 de Oct. de 2020
Thank you! This worked a treat.

Iniciar sesión para comentar.

Más respuestas (1)

JULIEN BARBAUD
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 MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by