Solving 4 linear equations with 4 unknowns (but vector variables)
3 views (last 30 days)
I am trying to find a solution for the following problem. I have 4 equations with 4 unknowns that I want to solve. I already found some handy topics, except for the fact that some of the variables are a vector consisting of 65 values. I want to find 4 unknowns which are also vectors with 65 values. For single variables I managed to do this but with 65 values per variable this becomes quite difficult for me.
Except for the 4 unknowns all other values are known. F_By and x are both a vector of (1x65 double), L_platform is just a single scalar value. I want to solve this so that the 4 unknowns include all 65 values. I hope someone can help me out with this and I appreciate the help!
syms F_Dx F_Gx F_Dy F_Gy
eq1 = F_Dx - F_Gx
eq2 = F_Dy + F_Gy -F_By
eq3 = F_Gy .* 0.5 .* (L_platform - x) - F_By .* (L_platform - x) + F_Gx * 0.5 * h
eq4 = F_Dx .* 0.5 .* h - F_Dy .* 0.5 .* (L_platform - x) - F_By .* 0.5 .* (L_platform - x)
sol = solve(eq1, eq2, eq3, eq4)
darova on 18 Mar 2021
Use for loop
c = [ 1 2 3 ];
res = c*0;
for i = 1:length(c)
f = c(i)*x + c(i)/10;
res(i) = double(solve(f));
Ivo Houtzager on 18 Mar 2021
Edited: Ivo Houtzager on 18 Mar 2021
Rewrite the linear equations to the linear matrix form of Y = A * X and then solve this linear matrix problem, see the following matlab code as example.
n = 65;
F_By = randn(n,1);
x = randn(1);
h = randn(1);
L_platform = randn(1);
L_min_x = L_platform - x;
Y = [zeros(n,1);...
A = [eye(n) -eye(n) zeros(n) zeros(n);...
zeros(n) zeros(n) eye(n) eye(n);...
zeros(n) 0.5.*h.*eye(n) zeros(n) 0.5.*L_min_x.*eye(n);...
0.5.*h.*eye(n) zeros(n) -0.5.*L_min_x.*eye(n) zeros(n)];
X = pinv(A)*Y;
F_Dx = X(1:n,1);
F_Gx = X(n+1:2*n,1);
F_Dy = X(2*n+1:3*n,1);
F_Gy = X(3*n+1:4*n,1);