solve_system

solve_system - %obtains the first 2 columns of the vector...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [x y] = solve_system(vec,vec2) %Write a function called solve_system that solves a system of linear %equations. %Your function will have two inputs : %- A vector consisting of the coefficients of the first linear equation % of the form Ax+By=C, which would be [A B C]. %- Another vector consisting of the coefficients of a second line % equation, with the same form as the first input. %Your function should have two outputs: the x and y value of the %solution. A = vec(:,1:end-1);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %obtains the first 2 columns of the vector array B = vec2(:,1:end-1); %obtains the first two columns of the vector2 array new = [A;B]; %vertically concatenates the new arrays C = vec(:,end); %gets the last column of the vector array D = vec2(:,end); %gets the last column of the vector2 array new2 = [C;D]; %vertically concatenates the new arrays sol = new\new2; %solves the system of equations by back-dividing x = sol(1,1); %the x value is the 1st entry fo y = sol(2,1); y...
View Full Document

This note was uploaded on 10/21/2010 for the course CS 1371 taught by Professor Stallworth during the Spring '08 term at Georgia Tech.

Ask a homework question - tutors are online