Matlab solve linear system with condition to x - matlab

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.

Related

Matlab - determinant of covariance matrix coming out as zero

I'm trying to calculate the determinant of a 171x171 covariance matrix in matlab but the determinant is coming out as zero. I know the matrix is not singular because I am able to calculate the inverse of the matrix but because the numbers in the covariance matrix are quite small (between e-02 and e-05), I think matlab rounds to zero at some point because the numbers become so small.
I tried installing the symbolic toolbox and making the covariance matrix symbolic to calculate the determinant but my computer couldn't really handle it and kept crashing. Does anyone have an idea of a workaround/ know of a way of dealing with a determinant that is close to zero, but not actually zero?

Matlab: Reduce second order matrix differential equation to standard eigenproblem

I want to obtain the natural frequencies of a simple mechanical system with mass matrix M and stiffness matrix K (.mat-file -> Download):
Mx''(t)+Kx(t)=0 (x= Position).
It means basically, that I have to solve det(K-w^2*M)=0. But how can I solve it in Matlab (or if necessary reduce it to a standard eigenvalue problem and solve it then)? The matrices are definitely solvable with Abaqus (FEM Software), but I have to solve it in Matlab.
I tried the following without success: det(K-w^2*M)=0 => det(M^-1*K-w^2*I)=0 (I := unity matrix)
But solving this eigenvalue problem with
sqrt(eigs(K*M^-1))
delivers wrong values and the warning:
"Matrix is singular to working precision.
In matlab.internal.math.mpower.viaMtimes (line 35)"
Other wrong values can be obtained via det(K-w^2*M)=0 => det(I/(w^2)-M*K^-1)=0:
1./sqrt(eigs(M*K^-1))
Any hint would help me. Thanks in advance.
As #Arpi mentioned, you actually want to solve the generalized eigenvalue problem:
K*x = w^2*M*x
Since your matrices K and M are apparently singular (or just one of them), it is not possible to use eigs, but you have to use eig:
V = eig(K,M);
w = sqrt(V);

Finding Eigenvalue and Eigenvector of a symmetric n*n matrix in Matlab

I need to find the eigen value decomposition of the symmetric matrix in Matlab. But I do not want to use the matlab inbuilt function eig Can anyone tell me efficient algortihm. I have already implemented the power Iteration Algorithm but it is not suitable for my project because it gives the best value in eigenvalue and eigen vector. Looking forward for suggestions.
PS: I am using eigenvalue decomposition several time in my algorithm...

Matrix equation in Matlab

I have a matrix equation and I want to solve it in MATLAB. The equation is
X^(-1)AX=B.
Where X is an unknown symmetric 3x3 matrix, A is known and B is a diagonal matrix (There isn't any condition on B's elements, just diagonal).
Please help me solve this problem!
From the information you've given it appears that you are looking for a symbolic solution which Matlab is not the best at (usually Mathematica is prefered or check out Wolfram Alpha). If you absolutely need Matlab then you could use the 'solve()' command.
However, honestly you are dealing with a rather simple linear system of small dimensions so it is probably easiest to just work this out by hand. Check out Matrix Cookbook for help. Also it really just looks like you are just trying to solve for the eigenvector matrix so possibly the command eig() might help ??

Finding eigenvalues in MATLAB without using eig function

I'm trying to find eigenvalues of a matrix without using eig function (my homework says so). In Matlab, I define the matrix and identity matrix. But I cannot set up this equation:
A - x*I
x here is lambda, A is the matrix that I should find eigenvalues of and I is the identity matrix. If you know how to find eigenvalues, you supposed to understand this. How can I go through?
you can get some inspiration here: http://en.wikipedia.org/wiki/Eigenvalue_algorithm
if the matrix is fixed size, you can easily do the det(A-lambda*eye)=0 solving by yourself and use that.
With power iteration you can already find the dominant eigenvalue, and I knew there was an extension to this algorithm to also find the other eigenvalues, but cannot recall how that works :(