Question

# Write a MatLab function J = Jcb(f, x) that computes the jacobian of the vector f...

Write a MatLab function J = Jcb(f, x) that computes the jacobian of the vector f of functions of x. Input f is the vector of functions [f1(x1, x2, x3...); f2(x1, x2, x3...); ...] and inout x is a vector of unkown x [x1; x2; x3;...]. Output J is the jacobian square matrix of vector f.

#### Homework Answers

Answer #1

MATLAB Script:

close all
clear
clc

syms x1 x2 x3 x4
f1(x1,x2,x3,x4) = 1*x1 + 2*x2 + 3*x3 + 4*x4;
f2(x1,x2,x3,x4) = 2*x1 + 3*x2 + 4*x3 + 5*x4;
f3(x1,x2,x3,x4) = 3*x1 + 4*x2 + 5*x3 + 6*x4;
f = [f1; f2; f3]
x = [x1; x2; x3; x4]
J = Jcb(f, x)

function J = Jcb(f, x)
J = [];
for i = 1:length(x)
J = [J diff(f, x(i))];
end
end

Sample Output:

f(x1, x2, x3, x4) =
x1 + 2*x2 + 3*x3 + 4*x4
2*x1 + 3*x2 + 4*x3 + 5*x4
3*x1 + 4*x2 + 5*x3 + 6*x4
x =
x1
x2
x3
x4
J(x1, x2, x3, x4) =
[ 1, 2, 3, 4]
[ 2, 3, 4, 5]
[ 3, 4, 5, 6]

Know the answer?
Your Answer:

#### Post as a guest

Your Name:

What's your source?

#### Earn Coins

Coins can be redeemed for fabulous gifts.

##### Not the answer you're looking for?
Ask your own homework help question
ADVERTISEMENT
##### Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

ADVERTISEMENT
##### Active Questions
• XYZ is a calendar-year corporation that began business on January 1, 2017. For 2018, it reported...
asked 17 minutes ago
• Although aging and death are realities that all individuals have to deal with at some point...
asked 41 minutes ago
• Implement the following functions with AVR assembly language 1) 2-byte addition (i.e, addition on 16-bit numbers)...
asked 50 minutes ago
• Assume you have a chemical compound (HA) that is a weak acid which changes color upon...
asked 1 hour ago
• A company has two divisions. The first division consists of project management and generated \$4,523,367 of...
asked 1 hour ago
• Practice Quiz 1 Use the following information to answer questions 1 through 5.                              &
asked 1 hour ago
• 3) The corrosion of iron is an electrochemical process that involves the standard reduction potentials given...
asked 1 hour ago
• Type or paste question here In 2015, the United States is still recovering from the recession....
asked 2 hours ago
• Failures of a critical machine part due to cyclical vibration has a gamma distribution with a...
asked 2 hours ago
• f(x)=ln(1+2x), a=4,n=3,3.7<=x<=4.3 (b) Use Taylor's Inequality to estimate the accuracy of the approximation f  Tn(x) when x...
asked 2 hours ago
• What is the meaning of convergent and divergent series? Explain your answer with example.
asked 2 hours ago
• Based on what you have learned in the textbook about feminism, discuss the approach by the...
asked 3 hours ago