jploveless / Blocks

Analysis of plate boundary deformation using geodetic data
MIT License
28 stars 18 forks source link

avoid sp==0 (sign of phi) in faultobliquemerc.m #3

Closed elevans11 closed 4 years ago

elevans11 commented 4 years ago

Hi Jack!

There had been a weird issue in Blocks where it would sometimes give all NaNs in more recent version of Matlab. I found it! 

The line in faultobliquemerc (line 72):  phip = atand(-cosd(lambdap - lambda1)./tand(phi1)); was sometimes returning exactly 0 in more recent versions of Matlab (instead of like ~1e-13). So then the next line sp = sign(phip); is also zero, which then zeroed out the projections. I just added: sp(sp==0) = 1;

And everything looks fine now! 

Thanks!

brendanjmeade commented 4 years ago

Can confirm that this fixed the issue I encountered under 2020. Thanks @elevans11!