Generate a loop with Guassian Elimination for multiple values of one variable
2 次查看(过去 30 天)
显示 更早的评论
I'm trying to generate a loop that solves a system of equations in the matrix form Ax=b that has a solution vector x that then populates a 15 column solution matrix using all 401 possible values for F1. I've transposed my solution vector x but it currently only populates as a 1x15 with the final value of F1 which is 200.
F1 = 0:0.5:200;
F2 = 55;
F3 = 35;
%input left side of equilibrium equations
A = [1 1 0 0 0 0 0 0 0 0 0 0 0 0 0;
1 0 0 (1/sqrt(2)) 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 (1/sqrt(2)) 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 (3/sqrt(13)) 1 0 0 0 0 0 0 0 0;
0 0 -1 0 1 (2/sqrt(13)) 0 0 0 0 0 0 0 0 0;
0 0 0 0 -1 0 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 (3/sqrt(13)) 1 0 0 0 0;
0 0 0 0 0 0 0 -1 0 -(2/sqrt(13)) 0 1 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 (1/sqrt(2)) -(2/sqrt(5)) 0;
0 0 0 0 0 0 0 0 0 0 -1 0 -(1/sqrt(2)) (1/sqrt(5)) 0;
0 0 0 0 0 -(2/sqrt(13)) 0 0 0 (2/sqrt(13)) 0 0 0 (2/sqrt(5)) -(2/sqrt(5));
0 0 0 0 0 -(3/sqrt(13)) 0 0 -1 -(3/sqrt(13)) 0 0 0 -(1/sqrt(5)) -(1/sqrt(5));
0 0 0 -(1/sqrt(2)) 0 0 0 0 0 0 0 0 0 0 (2/sqrt(5));
0 0 0 -(1/sqrt(2)) 0 0 -1 0 0 0 0 0 0 0 (1/sqrt(5))];
%setup loop to solve equilibrium equations
for n = 1:length(F1);
%input right side of equilibrium equations
b = [F1(n)+F2+F3;
0;
0;
F1(n);
0;
0;
F2;
F3;
0;
0;
0;
0;
0;
0;
0];
x = (A\b)';
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!