Doing calculation across columns
17 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
madhan ravi
2019-4-22
D=zeros(500,5);
D=matrix;
D(:,5)=exp((-(matrix(:,2)-75)/2).^2)
更多回答(1 个)
JULIEN BARBAUD
2019-4-22
编辑:JULIEN BARBAUD
2019-4-22
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!