Tag Archives: matlab code

MATLAB code for Numerical calculation of Jacobian matrix for a complex number

In this post, I share a MATLAB code for numerical calculation of Jacobian matrix for a complex number.

Download

This code was developed by Sithan Kanna, based on my code. If you are just interested in Jacobian of a real number, please see this post.

http://youngmok.com/numerical-jacobian-matrix-matlab/

I really thank to Sithan Kanna for sharing this nice code. If you have a question on this code please send an email to sithankanna a-t gmail d-o-t com

Download

 

This is a sample result of the code

>> h=@(x)[x(1) ; conj(x(1))]; % nonlinear equation

conjug = 0;
real = 0;
x_test = [0.5*1j];
H = NumJacob(h, x_test, conjug, real)

H =

1.0000
-0.0000

 

Have a nice day, and thank you for visiting my blog.

-Mok-

 

—————————————————————————————————

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————

 

Numerical Jacobian matrix calculation method with matlab code

In this post, I share a numerical Jacobian matrix calculation method with matlab code.

Actually there is a function in Matlab inherently, but it is very complex. ( look at the function, NumJac ), So I made a very simple version. I wish this can help you.

You can download from here.

The attachment file includes 

1. NumJacob.m : main file it generates jacobian matrix. 

2. Demo.m : demo file

3. test_func.m : test function to show its demo

 

The below is a simple example.

>> NumJacob(@cos,1)

ans =

-0.8415

 

>> x0=[0;1]; other_param=[1;2];
>> df=NumJacob(@test_func,x0,other_param)

df =

1.0000 0
0 2.0000

 

 

Because the code is very easy, probably you can easily understand the codes.

Then, good luck ^^

if you have any question, please leave me a comment below.

 

Added on Feb 07. 2014

I am uploading another demo file to give a solution of Mahmudul’s request (for detail, see the comment).

This demo file is to get a numerical Jacobian for the below function

y1′ = y2*y3; y1(0) = 0
y2′ = -y1*y3; y2(0) = 1
y3′ = -0.51*y1*y3; y3(0) =1

Download this demo file. 

 

Added on Mar/21 2015

If you are interested in calculating numerical Jocobian matrix for a complex number, please read this post.

http://youngmok.com/matlab-code-for-numerical-calculation-of-jacobian-matrix-for-a-complex-number/

 

—————————————————————————————————

I am Youngmok Yun, and writing about robotics theories and my research.

My main site is http://youngmok.com, and Korean ver. is  http://yunyoungmok.tistory.com.

—————————————————————————————————