MATLAB Answers


How can I pass vector argument to a gradient and jacobian functions i.e. I want to be able to calculate gradient and jacobian at a particular point say X=[1 2] or U=[3 4]

Asked by upinderjeet
on 23 Mar 2013

I tried the following code in the command window:

L= x1^2+x2^2+u1^2+u2^2+2*x1*u1+2*x2*u2; >> Lx=gradient(L,X)

Lx =

 2*u1 + 2*x1
 2*u2 + 2*x2

>> Lu=gradient(L,U)

Lu =

 2*u1 + 2*x1
 2*u2 + 2*x2

>> Lxu=jacobian(Lx,U)

Lxu =

[ 2, 0] [ 0, 2]

>> Lux=jacobian(Lu,X)

Lux =

[ 2, 0] [ 0, 2]

Now in this case I know the jacobian will be same for all the cases but still I need to know how to do the same for some other complicated functions. *MY NEED IS THAT I SHOULD BE ABLE TO CALCULATE Lx,Lu,Lxu,Lux AT A PARTICULAR POINT AND THAT TOO RIGHT WHEN I CALL THE GRADIENT OR JACOBIAN FUNCTION RESPECTIVELY.*


Log in to comment.


No products are associated with this question.

0 Answers

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!