×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Jacobian Algorithm

Jacobian Algorithm

Jacobian Algorithm

(OP)
I am  trying to write a program in matlab to find Jaobian for any test function. As an example I am trying on Rosenbrock function and ,I think there is a minor error in the way I am defining the jacobian.
I highly appreciate if you would have a look at my Jacobian algorithm and let me know how I can change it so it will work.
-------------------------------------------------------------
rosenbrock function for 2n variables.

%rosenbrock function for 2n variables.

%function [fx] = rosenbrock(x)
function [Fx] = jrosenbrock(x)
x=[-1.2,1];

n = length(x);
fx =0 ;
Fx=[];
for i =2:2:n
 
  f_x(i-1)=10*(x(i) - x(i-1)^2);
  f_x(i)= (1-x(i-1));
    %afx = 100*(x(i) - x(i-1)^2)^2 + (1-x(i-1))^2;
  fx= (f_x(i-1))^2+(f_x(i))^2;
    
   
Fx=f_x';
Fx
end

-----------------------------------------------------------------------------------------------------------------------JACOBIAN CODE
epsi= sqrt(macepsi);
%fx=@rosenbrock;
Fx=@rosenbrock;
x=[-1.2 1];
%feval(fx,x);
%Fofx = feval(Fx,x);
n = length(Fx)
Jx =[];
for i = 1:n
    delta = x
    delta(i) = x(i)+ epsi;
    
    for j=1:n;
        %feval(Fx,delta);
        %Fdelta= Fx;
    
        Jx(j,i)= (feval(Fx,delta)- feval(Fx,x))/epsi;
    end
end

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources