Solving vector equations with matlab

  • Context: MATLAB 
  • Thread starter Thread starter gnome
  • Start date Start date
  • Tags Tags
    Matlab Vector
Click For Summary

Discussion Overview

The discussion revolves around solving a system of linear equations represented by an augmented matrix using MATLAB. Participants explore how to determine the values of a parameter (h) for which the system is consistent, particularly in the context of larger matrices where manual calculations may be impractical.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant inquires about finding values of h for consistency in a given augmented matrix using MATLAB, suggesting various methods including row reduction and variable matrix setup.
  • Another participant proposes calculating the determinant of the coefficient matrix to check for values of h that make it zero, indicating inconsistency.
  • A participant shares MATLAB code using symbolic variables to perform row reduction, but questions the relevance of the results when the determinant is zero.
  • Discussion arises about the meaning of "consistent" in relation to the uniqueness of solutions, with some participants clarifying that consistency can exist even with infinite solutions.
  • One participant expresses confusion about the responses, emphasizing that their original question was theoretical and not based on a specific problem, and seeks clarification on solving non-square systems in MATLAB.
  • Another participant mentions that MATLAB requires actual numbers in matrices, complicating the use of symbolic variables for certain operations.
  • Further discussion includes attempts to understand the output of MATLAB's row reduction and its implications for the original problem, with some participants expressing frustration over the utility of the results.

Areas of Agreement / Disagreement

Participants exhibit disagreement regarding the interpretation of consistency and the role of the parameter h in the system. There is no consensus on the best approach to solve the problem using MATLAB, and multiple viewpoints on the implications of the determinant and row reduction are presented.

Contextual Notes

Participants note limitations in understanding how to handle non-square matrices in MATLAB, as well as the challenges of interpreting results from symbolic computations. Some assumptions about the definitions of consistency and the nature of solutions remain unresolved.

gnome
Messages
1,031
Reaction score
1
I'm just starting (way overdue really) to learn how to use matlab.

Suppose you have a system of linear equations for which this is the augmented matrix:

[tex]\begin{array}{cccc}1 &5 &-3 &-4\\ -1 &-4 &1 &3\\ -2 &-7 &0 &h \end{array}[/tex]

how would you find (using Matlab) the value(s) of h for which it's consistent?

Obviously this example is trivial to solve by hand, but suppose it were a much bigger matrix. Is there a way to set up a matrix with variables for one or several elements and solve for those variables? Or, just do a row reduction while keeping the variables in place so you would then be able to determine the consistent values by inspection? Or some other way?
 
Physics news on Phys.org
Surely it's just a matter of getting Matlab to calculate the determinant of the coefficient matrix, and then checking for what values of the parameter it's equal to 0.
 
Last edited:
>> syms h
>> rref([1 5 -3 -4; -1 -4 1 3; -2 -7 0 h])

ans =

[ 1, 0, 7, 0]
[ 0, 1, -2, 0]
[ 0, 0, 0, 1]


h= 1 ?

Finding determinant for this matrix would require the matrix to be square.. which is kinda a bummer, since it isnt.
 
Last edited:
But the coefficient matrix is just

1 5 -3
-1 -4 1
-2 -7 0,

(excuse the lack of LaTeX), which has a determinant of 0, so it's not invertible. Thus your system is never consistent, no matter what the value of "h" is. And that's another thing, whatever is in the last column of the augmented matrix must be totally irrelevant to the consistency of the system, right (unless I have my terminology mixed up)?
 
Last edited:
If det of coefficient matrix is not equal to 0, the system is uniquely determined. But it will still be constistant even if its undertermined (infinity number of solutions, laying on same line, A isn't invertible, det of coefficient matrix = 0)
 
My bad, I thought "consistent" meant "has a unique solution".
 
Carefully scrutinizing this problem on paper, I've reached these results:

a=-7c+1
b=(-2a-5)/7
c=(1-a)/7

h= 14c + 2a + 3

I haven't graphed h against all variables but it should be pretty interesting to analyse it. I don't have all the necessary multivariable calculus math to analyse such a system though.

But here are a few solutions:
a=-6, b=1, c=1, h=5
a=-5/2, b=0, c=1/2, h=5
a=-17/2, b=12/7, c=1, h=0

I guess the matrix should then be:

[tex]\left(\begin{array}{abck}<br /> 1 & 0 & 0 & -7c+1\\ <br /> 0 & 1 & 0 & (-2a-5)/7 \\ <br /> 0 & 0 & 1 & (h-2a-3)/14<br /> \end{array}\right)[/tex]
 
Last edited:
Thanks, everyone, but I'm really puzzled by these responses. First of all, this was not an actual problem I was trying to solve; just a simple example that I thought would clarify my question.

Supposing that this particular one represented the matrix equation Ax = b, to solve it on paper I would (following the method described in my textbook) row-reduce it like this:

[tex]\begin{array}{cccc}1 &5 &-3 &-4\\ -1 &-4 &1 &3\\ -2 &-7 &0 &h \\ <br /> \\<br /> 1 &5 &-3 &-4\\ 0 &1 &-2 &-1\\ 0 &3 &-6 &h-8 \\<br /> \\<br /> 1 &5 &-3 &-4\\ 0 &1 &-2 &-1\\ 0 &0 &0 &h-5 \end{array}[/tex]

and I conclude that h = 5 is required to have a consistent system.
Now, if h = 5,
[tex]b = \left [ \begin{array}{c} -4\\ 3 \\ 5 \end{array} \right ][/tex]

and [itex]x_3[/itex] is a free variable so there will be an infinite number of solutions, right?

But all that is beside the point (unless what I just did is somehow wrong; if so please correct me).

My question is, suppose I'm dealing with Ax = b where part of b is unknown and A is a 400 x 100 matrix and x and b are each 100 x 1 so I don't feel up to doing the row reduction on paper, and the coefficient matrix is not square, so as far as I know there's no determinant test that will tell me anything about Ax = b.

Is there any way to solve such a thing with Matlab?
 
>> rref();

Will give you reduced matrix b, usually in Identity-augment form.
 
  • #10
Finally we get to the crux of the matter.

It accepts only actual numbers in the matrix. I can't find any way to enter a variable as an element of a matrix.
 
  • #11
Refer to my first post please

>> syms h
>> rref([a11 a12 a13; a21 a22 a23; a31 a32 h])

Use syms to create a variable
e.g.: syms x
 
  • #12
I don't understand what that's doing, and it seems to be coming up with the wrong answer.
 
  • #13
OK, maybe I see what it's doing, but I don't see how to get anything useful out of it.
If you start with the matrix
[tex]\begin{array}{cccc}1 &5 &-3 &-4\\ -1 &-4 &1 &3\\ -2 &-7 &0 &1 \end{array}[/tex]

it reduces in a few steps to
[tex]\begin{array}{cccc}1 &0 &7 &1\\ 0 &1 &-2 &-1\\ 0 &0 &0 &-4 \end{array}[/tex]

You can then continue by dividing the last line by -4 and use the resulting 1 to eliminate the entries at (1,4) and (2,4) you would get what Matlab is showing as the "answer". But what kind of answer is that? What useful information (if any) can I get out of that?

(But that's only if you start off with h = 1. Is it just arbitrarily replacing h with 1?)
 
Last edited:

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 4 ·
Replies
4
Views
10K
  • · Replies 5 ·
Replies
5
Views
3K
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K