Question

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.

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]

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 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 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 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 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) . 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 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 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 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 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

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 17 minutes ago

asked 41 minutes ago

asked 50 minutes ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago

asked 3 hours ago