MATLAB system of equations with time step

I have a system of equations:

7.8w + 5.7y + 31.9z = Data1

3.1x - 1.4z = Data2

w + x -y + z = Data3

17.5w + 3x - 2.8y + 6.2z = Data4

Where the data is list of values at a time step.

I currently have:

w = 1;
x = 1;
y = 1;
z = 1;
A = [7.8 0 5.7 31.9; 0 3.1 0 -1.4; 1 1 -1 1; 17.5 3 -2.9 6.2];
X = [w; x; y; z];
B = ??????;
X = A\B;

I believe I need construct a matrix of 4 rows and as many columns as I have rows in my data, but I'm not sure how I would write that.

Upvotes: 0

Views: 60

Answers (1)

lennon310
lennon310

Reputation: 12689

B = reshape(data, 4, length(data)/4);

Every 4 elements in your data array (every column in B) will refer to Data1, Data2, Data3, and Data4 in your equations.

Upvotes: 1

Related Questions