Solving 4 linear equations with 4 unknowns (but vector variables)

3 ビュー (過去 30 日間)
Tim Jonkman
Tim Jonkman 2021 年 3 月 18 日
編集済み: Ivo Houtzager 2021 年 3 月 18 日
Hi there,
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!
Kind Regards,
Tim
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)

回答 (2 件)

darova
darova 2021 年 3 月 18 日
Use for loop
c = [ 1 2 3 ];
res = c*0;
syms x
for i = 1:length(c)
f = c(i)*x + c(i)/10;
res(i) = double(solve(f));
end

Ivo Houtzager
Ivo Houtzager 2021 年 3 月 18 日
編集済み: Ivo Houtzager 2021 年 3 月 18 日
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);...
F_By;...
F_By.*L_min_x;...
0.5.*F_By.*L_min_x];
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);

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by