Writing a code with the size of the (square) matrix increasing in dimensions
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to write a code to solve for shift factors. The problem I'm having is that what I need will require the code to solve for 2 variables then 3 then 4 but without the previous variables changing. I need a general code that will first solve 2 variables (2x2 matrix) then 3 variables with the first 2 the same (3x3 matrix) then 4 variables with the first 3 the same (4x4 matrix) and so on. How would I solve for this where the size of the matrix increases and the previously solved variables remain constants?
Here's what I have so far but I need a loop of some sort to make it general.
SP = xlsread('Shift Factor Data',-1);
SPj = SP(1:end);
MCC = xlsread('Shift Factor Data',-1);
MCCj = MCC(1:end);
A = [SPj(1,1) M(1,1); SPj(1,1) SPj(2,1)];
B = [-MCCj(1,1); -MCCj(2,1)];
Shift_Factor = A\B
C = [SPj(1,1) 0 0; SPj(1,1) SPj(2,1) 0; SPj(1,1) SPj(2,1) SPj(3,1)];
D = [-MCCj(1,1); -MCCj(2,1); -MCCj(3,1)];
SF = C\D
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!