EGR 103/Linear Algebra

From PrattWiki
Jump to navigation Jump to search
  • The first two problems simply require setting up the appropriate matrix of coefficients of your unknowns and vector of solutions, which can then be used to solve for your unknowns using left divide.
  • The last two problems require much the same, only in some kind of a loop. You will need to calculate the matrix of coefficients and/or solutions each time through the loop, making changes to whichever parameters vary. Note also that when you use left divide, you are solving for all of the unknowns at once. If you want to store a particular value, you need to extract it. For instance:
for k=1:10
     % calculate coefficients and solution matrices, sometimes called A and b respectively
     MySolutions = A\b;
     FirstVal(k) = MySolutions(1);
     SecondVal(k) = MySolutions(2);
     % etc.
end

If you have two parameters, you will likely have a double loop and thus two different indices, rather than just \(k\).