Doing calculation across columns
15 views (last 30 days)
Show older comments
Nick DeMarchis
on 22 Apr 2019
Commented: Jenny Hall
on 22 Oct 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!
0 Comments
Accepted Answer
madhan ravi
on 22 Apr 2019
D=zeros(500,5);
D=matrix;
D(:,5)=exp((-(matrix(:,2)-75)/2).^2)
More Answers (1)
JULIEN BARBAUD
on 22 Apr 2019
Edited: JULIEN BARBAUD
on 22 Apr 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
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!