Derivative of function with pointwise operations

Frank Hrebabetzky frank at photonita.com.br
Mon Jul 21 17:33:25 CEST 2008


I want to plot a 3D parametric surface. In order to apply eval3dp, it 
must accept vectors of equal size as arguments. The only way I found is 
using pointwise operations, e.g.

----------------------------------------------
function [x,y,z] = Cone (r, phi, alpha)
   x = r .* cos(phi) * sin(alpha)
   y = r .* sin(phi) * sin(alpha)
   z = r * cos(alpha)
endfunction

deg = %pi/180;

function [x,y,z] = Cone30 (r, phi)
   [x,y,z] = Cone (r, phi, 30*deg)
endfunction;
-----------------------------------------------

Now I run into problems when I want to calculate derivatives:

-->derivative(Cone30,[1;0])
  !--error 9999
inconsistent element-wise operation
at line       2 of function Cone called by :
line     2 of function Cone30 called by :
line     8 of function %R_ called by :
line    12 of function %deriv1_ called by :
line    59 of function derivative called by :
derivative(Cone30,[1;0])

In fact, the debugger shows that Cone30 is called with 2 vectors of 
different size, which forbids pointwise operations.

So how a function would look like, which can be called by 'eval3dp' and 
by 'derivative'?

-- 
Frank Hrebabetzky	Tel. (48) 3239 2258
Photonita Ltda.		http://www.photonita.com.br
Brazil



More information about the users mailing list