Effacer les filtres
Effacer les filtres

How to find a matrix of solutions for linear system

3 vues (au cours des 30 derniers jours)
Ali Alnemer
Ali Alnemer le 18 Juil 2017
Hi,
I am a beginner in matlab and facing difficulty coding the following:
I have a system of equations with variables (x1, x2, x3 and x4)
the equations are
first equation: 42.4*x1 + 83*x2 + 100.1*x3 + 100*x4 = 77
second equation: 46.4*x1 + 77.2*x2 + 84.9*x3 + 100*x4 = 70.9:76.9
Third equation: 679*x1 + 778.81*x2 + 745.42*x3 + 692.14*x4 = 715:725
fourth equation: 100.2*x1 + 84.16*x2 + 70.1*x3 + 114.232*x4 = 91:93
the range of variables (x1, x2, x3, x4) is, for example, from (0.01: 0.4).
We will not have one solution since we have range of values in 2nd, 3rd and 4th equations.
The purpose is that I got a matrix of solutions from only the first equation. There will be finite solutions because we give a range for x1,x2,x3,x4.
Then we substitute this matrix of solutions in the second equation, and any solution that gives value from 70.9 to 76.9 will be accepted. Others will be rejected. hence the new matrix of solutions will be minimized.
and then we do the same thing with the new matrix in the third equation...... then same process in fourth equation until we end up with very small matrix of solutionsn( like 10 solutions)
I know that (loops) method may do this, but I don't know how to code it using Loops.
Or there might be another command or function that does this job.
Your help is appreciated.
  2 commentaires
John D'Errico
John D'Errico le 18 Juil 2017
I'd suggest you obtain an interval arithmetic tool. There are several to be found for MATLAB. One that I found is free (runs on windows or linux, may require compilation), the other for pay, but will run on any system.

Connectez-vous pour commenter.

Réponses (2)

Torsten
Torsten le 18 Juil 2017
[X1 X2 X3 X4]=ndgrid(77,70.9:0.5:76.9,715:725,91:0.2:93];
B=[X1(:) X2(:) X3(:) X4(:)].';
A=[42.4 83 100.1 100;46.4 77.2 84.9 100;679 778.81 745.42 692.14;100.2 84.16 70.1 114.232];
X=A\B;
Best wishes
Torsten.

John D'Errico
John D'Errico le 18 Juil 2017
Use an interval arithmetic tool. There are two to be found if you look on the MATLAB Central link exchange. One is free, but it will probably require a compile.
You could also write a simple interval arithmetic tool, that need only apply to multiplies and additions.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by