{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lab7 - Engineering 7 Introduction to Programming for...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Engineering 7: Prof. Alexandre Bayen Introduction to Programming for Engineers Spring 2011 Lab 7: Least Squares Regression Date Assigned: 5:00pm, Friday – Mar 25. Date Due: 5:00pm, Friday – April 1. Problem 1: Do Problem 12.8 in the Reader. Clarifications : You may assume that b is a column vector and that the number of elements in b is the same as the number of rows in A . The output x should be a column vector. You may assume that in the case of an infinite number of solutions, the A matrix has more columns than rows, i.e. A is fat. In the case that there are an infinite number of solutions, you should solve the system using x = pinv(A)*b . >> A = reshape(1:15, 3, 5); >> b = [-5; -4; -3]; >> [N, x] = myNumSols(A,b) N = Inf x = 1.0000 0.6000 0.2000 -0.2000 -0.6000 >> b = [-1.5; 2; 7]; >> [N, x] = myNumSols(A,b) N = 0 x = [] >> A = 3*eye(5); >>b = [1; 2; 3; 4; 5]; >> [N, x] = myNumSols(A,b) N = 1 x = 0.3333 0.6667 1.0000 1.3333 1.6667
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Engineering 7: Prof. Alexandre Bayen Introduction to Programming for Engineers Spring 2011 Problem 2: Consider the following network consisting of two power supply stations denoted by S1 and S2 and five power recipient nodes denoted by N1 to N5. The nodes are connected by power lines which are denoted by arrows, and power can flow between nodes along these lines in both directions. Let d i be a positive scalar denoting the power demands for node i, and assume that this demand must be met exactly. The capacity of the power supply stations is denoted by S. Power supply stations must run at their capacity. For each arrow, let f j be the power flow along that arrow. Negative flow implies that power is running in the opposite direction of the arrow. Write a function with header [f] = myFlowCalculator(S, d) where S is 1x2 vector representing the capacity of each power supply station, and d is a 1x5 row vector representing the demands at each node, i.e.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern