Graphics Programs Reference
In-Depth Information
if A(i,k) ˜= 0
lambda = A(i,k)/A(k,k);
A(i,k+1:n) = A(i,k+1:n) - lambda*A(k,k+1:n);
b(i)= b(i) - lambda*b(k);
end
end
end
%--------------Back substitution phase-----------
fork=n:-1:1
b(k) = (b(k) - A(k,k+1:n)*b(k+1:n))/A(k,k);
end
Simultaneousequationscan also be solvedinMATLABwith the simple command
b (see below).
MATLAB can beoperatedinthe interactive modethrough its command window,
whereeach command isexecuted immediatelyuponits entry. In this modeMATLAB
acts like an electroniccalculator. Here is an example of an interactive session for the
solution of simultaneousequations:
\
A
>>A=[210;-122;014];%Input3x3matrix
>>b=[1;2;3];
%Inputcolumnvector
>>soln=A\b
%SolveA*x=bbyleftdivision
soln =
0.2500
0.5000
0.6250
isMATLAB's promptfor input. The percentsign ( %) marks the
beginning of a comment.Asemicolon (;)hastwofunctions:itsuppresses printout
of intermediate results and separates the rowsofamatrix. Without a terminating
semicolon, the result of a command wouldbe displayed. For example, omission of
the last semicoloninthe line defining the matrix A wouldresult in
The symbol
>>
>>A=[210;-122;014]
A=
2
1
0
-1
2
2
0
1
4
Search WWH ::




Custom Search