Linear algebra Equation Learning
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Matt Baron
el 5 de Jun. de 2018
Respondida: Walter Roberson
el 5 de Jun. de 2018
If I am following along a text book to learn linear equations; how do I get my variable to update without reentering it?
a=[1 5 7] %setup row 1
b=[-2 -7 -5] %setup row 2
y=[a;b] %setup matrix
c=a*2 %setup var c to multiply all of a by 2
b=b+c %add c to b
y
at this point, y is still [1 5 7;-2 -7 -5]
how do I get y to update automatically? I don't want to have reenter it every time?
I just started my linear algebra course and I want to use MATLAB to learn it. I am not interested in just blindly solving the equations automatically.
Please help!! ;)
0 comentarios
Respuesta aceptada
Walter Roberson
el 5 de Jun. de 2018
You cannot do that. You can get closer using Symbolic Toolbox and subs().
In MATLAB, when you refer to a variable, the current value of the variable is always copied and the copy is used.
Now, you could do
syms a b
y = [a;b]
c = a*2
at this point, y would refer to the symbols a and b, and c would refer to twice the symbol a. And you could, at that point, do
subs(y, b, 7)
and you would get [a; 7]
However, if you a proceeding this way, then when you get to
b = b + c
then you have a problem.
You want name variables to refer to the variable rather than to copy the current value of the variable, such as your y = [a;b] you want y to refer to b rather than to copy the current value of b. Okay, so then what does
y = y + c
mean? To be consistent with what you are asking, the y on the right hand side to refer to y rather than copy it. So you would be saying that y has to be defined as referring to itself plus c. And the only way to make that logically consistent, that y plus c is the same as y, is if either c is 0 or else if y is +/- infinity .
If you want variable names to refer to the variable, then you need to do so consistently, and you would need statements such as
y = y^y
to declare that y on the left hand side refers to the symbol as both y's on the right hand side, so logically the reference chain would also have to mean that
y = (y^y)^(y^y)
and the only consistent solutions to that are y = -1, y = +1, y = +inf
The MATLAB system of having an appearance of a variable copy the current value of the variable presents a consistent and usable interface. Your proposal of having an appearance of a variable refer to the variable is not exactly inconsistent but it does force every statement to be resolved for logical consistency and makes it nearly useless to have statements such as
y = y + 2
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!