Solving linera equation AX=B in matlab - matlab

I have to solve following linear equation in Matlab
AX=B for X, where A - symetric positive definite upper triangular matrix (nxn), and B is matrix (mxn).
So far I have got code for solving such eqation where B is a vector. I have to change the code, to be able to calculate it for B as a (mxn) matrix
x(n)=b(n)/A(n,n);
for i=n-1: -1:1,
s=b(i);
for j=i+1:n,
s=s-A(i,j)*x(j);
end
x(i)=s/A(i,i);
end

Related

unconstrained optimization with Laguerre polynomial

I have a matrix X and a distance matrix D={d_ij}. I have an optimization problem to be solved. The problem is:
Theta_i is the unkown vectors and L is the Laguerre polynomial.
How I can write this objective function in matlab in order to use fminunc.
Thank you

CVX program for the matrix variable optimization

This question is about solving the problem on CVX using MATLAB:
My variable is W which is a N X N matrix. a is n X 1 vector. Sigma is a PSD matrix.
a) Can I solve this problem in Disciplined manner?
b) How to reformulate this in cvx since CVX says the Quadratic forms need to be with scalars. (equalities are matrix equalities).

nonlinear matrix equation solving in matlab

is it possible to solve below equation in matlab?
A*X+B*exp(X)=C
A, B are square and constant matrices. C is a constant and column matrix.
X is a column matrix which should be found.( exp() acts element by element on X).
If you are looking for a numeric method, you might want to try fsolve
X = fsolve( #(x) A*x + B*exp(x) - C, x0 );
Due to the non-linear nature of the problem you need to provide an initial guess x0 - the quality of which can affect the performance of the solver.

Matlab solve linear system with condition to x

I have a matrix A and an eigenvalue=1. Now I want to compute the eigenvector (without eig()).
I have to solve (A-I)x=0. With the help of a QR decomposition I have to solve Rx=0. Let´s say R is a nxn Matrix.
x=R\zeros(n,1)
does not work obviously because I just get the zero vector. That is why I want to set x(n)=1 but how can I solve that in Matlab?
Merry Chrismas.

How to solve the system of equation (simultanious) in matlab?

I have to solve the following equation in matlab but I have some requirement step which I must follow.
x+y=17
2x-y=10
"write the system of equation on Matrix form,
AX=B, and plug in the matrix A and the vector B in Matlab. Solve the system
of equations by calculating the inverse A-1, and then the product A-1 B using
Matlab. Also, report the determinant of A in each question".
Writing this as a matrix equation:
A * X = B
You have the following matrices:
A = [1 1; 2 -1];
B = [17; 10];
And you are looking for X. For this you need the matlab \ operator. I am going to leave it as an exercise for the student to figure out how to use that operator with this matrix and vector combination in order to produce X which is the solution of the equation.