sofacoustics / SOFAtoolbox

SOFA Toolbox (API for Matlab, Octave)
http://sofaconventions.org
European Union Public License 1.2
116 stars 31 forks source link

SOFAplotHRTF - Octave compatiblity fix #36

Closed SDX-LV closed 2 years ago

SDX-LV commented 2 years ago

Hello,

I use some of the features, primarily "SOFAplotHRTF" in the latest Octave 6.3 and there is an issue to get (Obj.SourcePosition_Type,'cartesian') support code to work.

The fix I use is replacing lines 131 and 132 from: Obj.SourcePosition(ii,1)=rad2deg(Obj.SourcePosition(ii,1)); Obj.SourcePosition(ii,1)=npi2pi(Obj.SourcePosition(ii,1),'degrees'); % requires Mapping toolbox in Matlab to Obj.SourcePosition(ii,1)=npi2pi(Obj.SourcePosition(ii,1)); % https://github.com/alfoltranteam/octave-map/blob/master/src/npi2pi.m Obj.SourcePosition(ii,1)=rad2deg(Obj.SourcePosition(ii,1));

npi2pi.m function may require Mapping toolbox, but there is an open source alternative from https://github.com/alfoltranteam/octave-map/blob/master/src/npi2pi.m which does not support 'degrees' mode. With this simple change the code should work both in Matlab and Octave irrespective of the Mapping toolbox.

Best Regrds, Sergejs

isfmiho commented 2 years ago

Dear Sergejs, thank you for pointing this out. I removed the usage of npi2pi completely, so we do not depend on an extra toolbox, extra documents, or outdated functions.