How to work with arrays with values of Log(0)?
9 次查看(过去 30 天)
显示 更早的评论
I am working with arrays that include zero values. One transformation I must do is apply logarithms to each value in the matrix. In the result, I need to do other operations but I have to skip the values that do not have a result of the logarithm. How can I do that?
Thanks
0 个评论
回答(1 个)
David Hill
2020-12-8
a=log(initialArray);
idx=initialArray~=0;
a(idx)=5*a(idx);%other calculations only perform on non-zero values of initial array
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Exponents and Logarithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!