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
Similar Questions
Write a MatLab code J = Jcb(X) that computes the jacobian of a nonlinear vector of...
Write a MatLab code J = Jcb(X) that computes the jacobian of a nonlinear vector of functions of X. Input X is a vector of unkown functions of X and output J is the jacobian of the nonlinear vector function of X.
Create a function x=backsub(U,y) in matlab that accepts as input arguments a nxn matrix U and...
Create a function x=backsub(U,y) in matlab that accepts as input arguments a nxn matrix U and n-vector y, and returns as output a column vector x consisting of the values of the unknowns x1; x2; : : : ; xn.
Write a function called sum_half that takes as input a square matrix A and computes the...
Write a function called sum_half that takes as input a square matrix A and computes the sum of its elements that are in the upper right triangular part of A, that is, elements in the diagonal and elements that are to the right of it. For example, if the input is [1 2 3; 4 5 6; 7 8 9], then the function would return 26. (That is, 1+2+3+5+6+9) Note, the function triu is not allowed. Please write as you...
Write a function in Matlab that takes as input the number of iterations k, the size...
Write a function in Matlab that takes as input the number of iterations k, the size n, and a sparse matrix A. Have this function run the Power method for k iterations on an initial guess the vector of 1’s and output the dominant eigenvalue and its corresponding eigenvector. Use only basic programming. Write out or print out your function.
IN MATLAB: Write a function file that takes a vector as an input and returns another...
IN MATLAB: Write a function file that takes a vector as an input and returns another vector with all repeated elements of the original vector. For example, the vector [3 4 1 0 4 -5 7 3] would return the vector [3 4]. Do not use the built-in function "repelem."
Write a script (must be titled “NumIntF”) in MATLAB that calculates the integration of function f(x)=cos(x)...
Write a script (must be titled “NumIntF”) in MATLAB that calculates the integration of function f(x)=cos(x) . exp(sin x), Using numerical integration method. When the user runs the script, he/she is prompted to input the lower and upper limits for numerical integration, both in radians, and your program outputs the integration result. You can use built-in trigonometric functions and the exponential function, but you are not allowed to use any built-in function to do the integration. You must use a...
Write a MATLAB function function [ AvgPos, AvgNeg ] = PosNegAverage ( X ) that calculates...
Write a MATLAB function function [ AvgPos, AvgNeg ] = PosNegAverage ( X ) that calculates average of positive, AvgPos, and negative, AvgNeg, elements of array X, using the for‐end loop and if‐elseif‐else‐end selection structure. Do not use build‐in MATLAN functions in calculations. Apply the developed function for the following vector X = [ ‐7, 1, 0, 0, 12, 6, 33.2, ‐7.5 ];
Write a function find square root(x) that takes as input a number x and as output...
Write a function find square root(x) that takes as input a number x and as output returns the square root of x. Your results should converge to at least 6 decimal places. matlab question
Write a function custom sort(v) that takes as input a vector v and as output returns...
Write a function custom sort(v) that takes as input a vector v and as output returns the vector w sorted into increasing order. For example, if the input is [−2 1 3 1 5], the output should be [−2 1 1 3 5]. Don’t use the built-in ”sort” function or anything similar. matlab question
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except...
*** Write a function called reverse_diag that creates a square matrix whose elements are 0 except for 1s on the reverse diagonal from top right to bottom left. The reverse diagonal of an n-by-n matrix consists of the elements at the following indexes: (1, n), (2, n-1), (3, n-2), … (n, 1). The function takes one positive integer input argument named n, which is the size of the matrix, and returns the matrix itself as an output argument. Note that...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
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