log function returning complex answers where there should be none
7 views (last 30 days)
So I have a 22*9 matrix. with 22 regions and 9 years. I am doing a decomposition analysis where need to calculate different factors contribution to the overalla change in total carbon emissions, between each set of years, for each region.
For some reason however, my code returns complex answers (for both Ln(r,m) and DeltaCO2CI) when there should only be real numbers. Can't figure out what i have done wrong?
here's the problematic part of the code:
Priyanshu Mishra on 28 Feb 2020
The complex values might be coming because value of co2r(r,m)-co2r(r,m-1) is negative. I would suggest you to put a break point and debug why these values are coming negative.