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!