Matlab: Reduce second order matrix differential equation to standard eigenproblem - matlab

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

Related

Is there a less time-consuming way to solve a Symmetric Matrix Equation

I'm currently working on solving an equation that involves a symmetric matrix C with 4 unknown variables, and a vector A of the same dimension. The equation I'm trying to solve is:
[C]*{A}=0 (1)
where * denotes matrix multiplication and { } denotes a vector.
The dimension of the C matrix can be as large as 100x100 or more, and I'm trying to define the unknown variables in C in a way that solves equation (1). One approach I've tried is to calculate the determinant of C, |[C]|=0, and solve for the 4 different variables inside.
However, when the dimension of the matrix is large, my current method in Mathematica is not able to solve the problem. I'm wondering if anyone has any suggestions for me to solve this equation more efficiently.
I'm open to using other programming languages such as Matlab or Python as well. Any suggestions or advice would be greatly appreciated.
Thank you in advance for your help and guidance.
I have tried solving this problem with 25*25 dimension. However, this size is not enough for the percision that I want for the variables.

solving a galois field matrix equation in matlab

I have the equation AX * C = AXB where all of the variables are square gf matrices of size n and the values are 0 or 1. AXB and AX are known, while C should be solved to B or an equivalent of it (there should be multiple solutions). Because X most likely isn´t regular (rank < n) not all of the variables in C can be calculated and i have to guess the rest after solving.
Question is: Can Matlab solve this equation (as far as possible), and in a better way than "manually" splitting the equation into n^2 equations?
I already tried to tell matlab that C is a symbol of, let´s say [8,8] and to solve AX*C==AXB, but solve doesn´t seem to work with galois fields.
Any hints on how to do this would be appreciated.

Numerical Instability Kalman Filter in MatLab

I am trying to run a standard Kalman Filter algorithm to calculate likelihoods, but I keep getting a problema of a non positive definite variance matrix when calculating normal densities.
I've researched a little and seen that there may be in fact some numerical instabitlity; tried some numerical ways to avoid a non-positive definite matrix, using both choleski decomposition and its variant LDL' decomposition.
I am using MatLab.
Does anyone suggest anything?
Thanks.
I have encountered what might be the same problem before when I needed to run a Kalman filter for long periods but over time my covariance matrix would degenerate. It might just be a problem of losing symmetry due to numerical error. One simple way to enforce your covariance matrix (let's call it P) to remain symmetric is to do:
P = (P + P')/2 # where P' is transpose(P)
right after estimating P.
post your code.
As a rule of thumb, if the model is not accurate and the regularization (i.e. the model noise matrix Q) is not sufficiently "large" an underfitting will occur and the covariance matrix of the estimator will be ill-conditioned. Try fine tuning your Q matrix.
The Kalman Filter implemented using the Joseph Form is known to be numerically unstable, as any old timer who once worked with single precision implementation of the filter can tell. This problem was discovered zillions of years ago and prompt a lot of research in implementing the filter in a stable manner. Probably the best well-known implementation is the UD, where the Covariance matrix is factorized as UDU' and the two factors are updated and propagated using special formulas (see Thoronton and Bierman). U is an upper diagonal matrix with "1" in its diagonal, and D is a diagonal matrix.

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 complex system of equations using matlab?

I have to analyze 802.11 saturation throughput using matlab, and here is my problem. I'm trying to solve parametric equations below (parameters are m,W,a) using solve function and i get
Warning: Explicit solution could not be found
How could I solve above equations using matlab?
I guess you were trying to find an analytical solution for tau and p using symbolic math. Unless you're really lucky with your parameters (e.g. m=1), there won't be an analytical solution.
If you're interested in numerical values for tau and p, I suggest you manually substitue p in the first equation, and then solve an equation of the form tau-bigFraction=0 using, e.g. fzero.
Here's how you'd use fzero to solve a simple equation kx=exp(-x), with k being a parameter.
k = 5; %# set a value for k
x = fzero(#(x)k*x-exp(-x),0); %# initial guess: x=0