How to solve overdetermined system of equations in Matlab? - matlab

my problem is the following.
Using linsolve function I am solving an overdetermined matrix 200x50 with very similar elements. Because of this, the solution that I get is not correct. Maybe some of you would have any suggestions how to solve such a system?
Best wishes,
Valerie

It's very likely that your system does not have a solution.
Rather than attempting to solve the system A*x=b, the next best thing you can do is to solve a similar problem:
min norm(A*x-b)
When the norm used is the Euclidean norm, the solution to the minimization problem is called a "Least-Squares solution"
The MATLAB syntax is:
x = A\b

Related

Matlab: How do i tell if the ode is stiff or not?

How do i check if the ode is stiff or not? Unfortunately, my problem is large so I cannot run different ode matlab solvers and compare their finish time. I hope I can tell from the ode itself directly. What are some characteristics of a stiff ode?
Unfortunately it is extremly hard to tell if the ode is stiff or not without running some integration methods especially if it's a large problem.
You could try to reduce the problem to a simpler one, e.g. Taylor-expansion and only taking the first 2 or 3 terms into consideration. Solving this problem could give you a hint whether your problem is stiff or not.
Note that I assumed your problem would be continous. Then according to Weierstraß' approximation theorem a series of polynomials (your Taylor expansion) would converge uniformly to your problem. This means if the problem with taylor series is stiff your original problem might be too.

How to solve a matrix optimization using MATLAB cvx

I have an optimization problem shown in uploaded figure file.
Determining the optimal matrix X maximizing given objective function is the problem.
However, since the function inside the log-function is non-concave, MATLAB CVX doesn't work.
How can I solve the problem? How should I transform the form?
Please give me a hand

Fit data with a numerical ode solution (on Matlab)

I am looking for a way to fit my experimental data by a theoretical model which is described by a non-linear differential equation.
Unfortunately this latter can only be solved numerically (by solving this second degree, non-linear differential equation).
I manage to solve the differential equation for a set of parameters using the ode45 Matlab solver but now I want to find the proper fit parameters of the model. Also, I may have to mention that my ode45 is initiated at z=zmax (max being large so I can assume it is infinity) by y(zmax)=y0 and yprime(zmax)=yprime0 and I solve backward (from zmax to z=0).
I am quite new to this kind of numerical problems, are there classical ways to solve such problems?
Does anyone knows if there is a Matlab procedure which would help me solve this? On which principles is it based/constructed? (if possible I'd like to know the theoretical trick to solve this problem in a smart way, not by trying all the possible sets of parameters which would be very time consuming (I have 5 fit parameters!).
Thank you for your precious help!
You have facy methods in the Optimization Toolbox. In case you don't have access to it, you could do it manually by:
Selecting a cost function between the experimental and model data. For example, mean-squared-error.
Doing heuristic optimization of the cost function. For example, Nelder-Mead method.

Solving 4th order ODE numerically with Matlab

I have been trying to solve this equation analytical, where C and L is constants:
There is no problem with the general solution, but with the conditions, the expression is close to unsolveable.
Now I'm trying to solve the problem with Matlab, where I believe i shall use the ode45 solver. I just don't know what to do with the integral and omega which is the value I'm trying to find.
I know that i haven't given any code snippet, but I just can't figure out how to solve this problem in Matlab.
I hope someone can help me, thanks.

How can I implicitly solve a single equation in Matlab?

The following equation is to be solved for M by MATLAB:
(Atemp/At)^2=1/M^2*((2/(gamma+1))*(1+(gamma-1)*M^2/2))^((gamma+1)/(gamma-1))
It is not possible to solve this equation symbolically. In Maple it is easily possible to solve such an equation implicitly; now, is there also a pre-made function in Matlab that does this for me? I could program one myself, but as my skills are limited, its performance would not fit my needs.
I would try using fzero, or if that encounters problems because of complex values/infinities, fminbnd.