E,M,F,lambda,x are Matrix or vector. The equation is:
E*x+F+Transpose(M)*lambda=0;
M*x-gamma=0;
Transpose(lambda)*(M*x-gamma)=0
The solutions of X and lambda are
lambda=-(M*E^(-1)*Transpose(M))*(gamma+M*Transpose(E)*F)
x=-E^(-1)*(F+Transpose(M)*Transpose(lambda))
How can I use Matlab's symbolic operation to obtain the X and lambda solutions of the above matrix equation? I don't want to deduce the formula myself. I want Matlab to deduce the formula automatically.
Related
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
I need to compute efficiently and in a numerically stable way the inverse CDF F^-1(y) (cumulative distribution function) of a probability function, assuming that both the PDF f(x) and the CDF F(x) are known analytically but the inverse CDF is not. I am doing this in MATLAB.
This is a root-finding problem for F(x)-y and I could use fzero:
invcdf = #(y, x0) fzero(#(x) cdf(x) - y, x0);
However, fzero is for a generic nonlinear function.
I wonder if there is some function, or I can write some algorithm that uses the explicit information that F(x) is a cdf (for example, we know that it is monotonically non-decreasing and we have its derivative, f(x)).
FYI, the shape of the PDFs I am working with is generic mixtures of Gaussian distributions multiplied by a polynomial of arbitrary degree (the CDF can be computed analytically in this case, although it's not pretty and it becomes expensive for polynomials with many terms). Note that I need to compute the inverse CDF for millions of CDFs within this class; a lookup table is not feasible.
For more mathematical details see also this related question on Math Exchange (here I am asking specifically for a MATLAB solution).
Here I've a transfer function matrix with size of (3*7):
G = [G11,G12,G13,G14,G15,G16,G17;
G21,G22,G23,G24,G25,G26,G27;
G31,G32,G33,G34,G35,G36,G37]
Is it possible to get A = [G*(G^(-1))T] symbolically in Matlab:
Where :
G^(-1) = inv(G) and (G^(-1))T = transpose of (inv(G))
Yeah it's possible but it may take a lot of time, and also it's possible that your computer runs out of memory. Matlab's symbolic operations are not very good, but here's the solution. First define the elements of your matrix as symbolic variables. syms G11 defines G11 as symbolic. than define your G matrix and go on. Than you can find the A matrix.
I should also mention that since your matrix is 3*7, I don't know if matlab have inverse command for non-square matrix, but you can have pseudo inverse. And if you want to do symbolic computations, Maple and mathematica are so much better. But matlab is better in Numerical computations .
I want to solve multiple measurement vector (MMV) sparse representation problem with CVX toolbox. I have a N*L matrix X. matrix X have only a few nonzero rows. I have system of equations Y=A*X. Y is M*L matrix of measurements (M
min Relax(X)
subject to Y=A*X
Realx(.) is a function that applies norm 1 to the vector t. (N*1)vector t consists of the norm 2 of each rows of matrix X. i.e. Relax(X)= norm_1(t) and t(i)=norm_2(X(i,:))
I can’t transform my objective function into a language that CVX can understand and solve.
Please tell me how I should change the problem objective and constraints that CVX could solve it.
'norms' is the cvx command you're looking for. Suppose sigma is some known parameter that allows Y to be only approximately equal to A*X (e.g. I tried it with sigma=10e-6). Then you could use this code:
cvx_begin separable
variable X(n,n)
minimize( norms(X,2,1) )
subject to
norm(Y - A*X,2)<= 10*sigma
cvx_end
I have to calculate:
gamma=(I-K*A^-1)*OLS;
where I is the identity matrix, K and A are diagonal matrices of the same size, and OLS is the ordinary least squares estimate of the parameters.
I do this in Matlab using:
gamma=(I-A\K)*OLS;
However I then have to calculate:
gamma2=(I-K^2*A-2)*OLS;
I calculate this in Matlab using:
gamma2=(I+A\K)*(I-A\K)*OLS;
Is this correct?
Also I just want to calculate the variance of the OLS parameters:
The formula is simple enough:
Var(B)=sigma^2*(Delta)^-1;
Where sigma is a constant and Delta is a diagonal matrix containing the eigenvalues.
I tried doing this by:
Var_B=Delta\sigma^2;
But it comes back saying matrix dimensions must agree?
Please can you tell me how to calculate Var(B) in Matlab, as well as confirming whether or not my other calculations are correct.
In general, matrix multiplication does not commute, which makes A^2 - B^2 not equal to (A+B)*(A-B). However your case is special, because you have an identity matrix in the equation. So your method for finding gamma2 is valid.
'Var_B=Delta\sigma^2' is not a valid mldivide expression. See the documentation. Try Var_B=sigma^2*inv(Delta). The function inv returns a matrix inverse. Although this function can also be applied in your expression to find gamma or gamma2, the use of the operator \ is more recommended for better accuracy and faster computation.