behavior of sph2cart() doesn't match matlab (?)
michael tesch
tesch1 at gmail.com
Fri Jan 16 09:35:13 CST 2009
thanks for your answer.
sorry, i should have removed the loop from the example snippet.
the point is that the code works in matlab, but doesn't work in octave,
because matlab's sph2cart() (apparently) accepts when TH and PHI
are scalars and A is a vector, whereas octave's sph2cart() bombs out.
xx,yy,zz,TH,PHI are all scalars. A is a vector (of points along a line)
and spoke should be the cartesian coordinates of the points along that line.
i have a workaround, but read that differences between octave and
matlab were considered bugs.
mt
On Fri, Jan 16, 2009 at 6:35 AM, Ben Abbott <bpabbott at mac.com> wrote:
>
> On Jan 15, 2009, at 8:57 PM, michael tesch wrote:
>
>> GNU Octave, version 3.0.2, on macosx, from 'port'.
>>
>> I can't actually verify this on the matlab side, but I got code that
>> was developed in matlab that did the following:
>>
>> for nsp=1:sz
>> [TH,PHI]=cart2sph(xx,yy,zz);
>> [X,Y,Z]=sph2cart(TH,PHI,A);
>> spoke=[X ;Y ;Z];
>> end
>>
>> Where xx,yy,zz,TH,PHI were all scalars, and A was a 1xN vector. The
>> result was that spoke was a matrix of 3xN.
>>
>> the Octave implementation of sph2cart() dies with an error about
>> mismatched dimensions of parameters.
>
>>
>
> I'm unable to reproduce any problem in the developers sources.
>
> Nothing depends upon "nsp", so why the loop?
>
> TH, PHI should each have same size as xx, yy, & zz. Are you sure A has the
> same size?
>
> To make certain everything is sized/shaped correctly, try inserting the line
> below after cart2sph
>
> whos xx yy zz TH PHI
>
> Ben
>
More information about the Bug-octave
mailing list