Hans
In matlab, the variables have to be defined before being used, otherwise you get the error "Undefined function or variable"
However, you could define a function, with the variables defined as parameters. That way, you can change the variables and have the matrix recalculated.
The only language that I know of that allow you to use variables before defining them is Maple. In Maple, the variables are treated symbolically, and don't ever have to be assigned a numeric value.
Here's an sample program illustrating the use of functions and recalculating the matrix.
function test
k1=5; k2=2; b1=3; b2=-9; m1=45.3; m2=12.1;
r1 = myMatrix(k1, k2, b1, b2, m1, m2)
m2 = 11;
r2 = myMatrix(k1, k2, b1, b2, m1, m2)
function R = myMatrix(k1, k2, b1, b2, m1, m2)
R=[ 0, -k2-b2, k2+b2+m2, -1
-k1-b1, k1+k2+b1+b2+m1, -k2-b2, 1];
The output is
r1 =
0 7.0000 5.1000 -1.0000
-8.0000 46.3000 7.0000 1.0000
r2 =
0 7.0000 4.0000 -1.0000
-8.0000 46.3000 7.0000 1.0000
Cheers
J. Vorwald