Entering Matrices and Vectors in MATLAB
Overview
In this first hands-on introduction to MATLAB you will start to become familiar
with the MATLAB
command window, entering matrices, making assignments, and performing basic
matrix and
vector operations .
Part I
The following commands should be entered and executed to understand how you can
enter
information and obtain results within a MATLAB session. (There is no need to
enter the
comments; they are included for your benefit as you read this document.)
Online help
>> help help |
% Online help can be very useful! |
|
|
• Elementary calculations
>> 2 + 3
>> 4 + sqrt(2)
>> 5 + sqrt(2);
>> ans |
% the semi-colon suppresses the answer
% to see the last answer |
|
|
• Entering Vectors
>> v = [ 1 2 3 ]
>> v2 = [ 1, 2, 3 ]
>> w = [ 1; 2; 3 ]
>> w2 = [ 1
2
3] |
% row vector
% there is no difference between v and v2
% column vector
% is there a difference if we enter
% a column vector as follows? |
|
|
• Entering Matrices
>> A = [ 1 2 3; 4 5 6; 7 8 9 ]
>> A = [ 1, 2, 3; 4, 5, 6; 7, 8, 9 ]
>> A = [ 1, 2, 3; 4, 5, 6; 7, 8, 9 ]
4 5 6
7 8 9] |
% matrix
% the same matrix
% and a third definition
% of the same matrix |
|
|
• Editing Coefficients in a Vector or Matrix
>> w(1) = 0
>> A(2,3)=10 |
% change first entry in vector w
% change one coefficient in matrix A |
|
|
• Transpose
>> w'
>> A' |
% transpose of a column vector
% transpose of a matrix |
|
|
• Accessing Defined Quantities
>> who
>> whos
>> A, v, w
>> |
% list of all assigned variables
% how do who and whos differ?
% type the name of a variable
% to see its contents |
|
|
• Miscellaneous Vector and Matrix Operations
>> B = [ 1 0 -1; 0 3 5; 6 2 3]
>> C = [4 -1 3; 0 2 -5]
>> z = v + 2*w'
>> A + B
>> A - C
>> A * B
>> C * A
>> A * C
>> A'* B'
>> B'* A'
>> (A*B)' |
% define 3x3 matrix B
% define 2x3 matrix C
% compute these quantities
% be sure you understand each result
% (particularly the ones that are not defined)
|
% which of A'*B' and B'*A' equals (A*B)'? |
|
|
• Building Matrices from Blocks
>> D = [ A B ]
>> E = [ A B B A ] |
% (or [ A B; B A ]) >> >> |
|
|
• Selecting Sub-Vectors and Sub-Matrices
>> D(:,3)
>> D(2,:)
>> E(1:3,:)
>> E(2:4,1:3) |
% 3rd column of D
% 2nd row of D
% 1st 3 rows of E
% a 3x3 submatrix of E |
|
|
• Special Matrices
>> help eye
>> help zeros
>> help ones |
% identity matrix
% zero matrix
% matrix with all entries equal to one |
|
Challenge: Create the 3×6 zero matrix , the 4×4 identity matrix, and the
5×3 matrix
with all entries equal to 2. |
|
|
• Exiting MATLAB
>> quit |
|
Start solving your Algebra Problems
in next 5 minutes!
|
|
|
|
Algebra Helper
Download (and optional CD)
Only $39.99
|
Click to Buy Now:
OR
|
|
|
|
|
|
2Checkout.com is an authorized reseller
of goods provided by Sofmath
|
|
Attention: We are
currently running a special promotional offer
for Algebra-Answer.com visitors -- if you order
Algebra Helper by midnight of
December 22nd
you will pay only $39.99
instead of our regular price of $74.99 -- this is $35 in
savings ! In order to take advantage of this
offer, you need to order by clicking on one of
the buttons on the left, not through our regular
order page.
If you order now you will also receive 30 minute live session from tutor.com for a 1$!
|
You Will Learn Algebra Better - Guaranteed!
Just take a look how incredibly simple Algebra Helper is:
Step 1
: Enter your homework problem in an easy WYSIWYG (What you see is what you get) algebra editor:
Step 2 :
Let Algebra Helper solve it:
Step 3 : Ask for an explanation for the steps you don't understand:
Algebra Helper can solve problems in all the following areas:
- simplification of algebraic expressions (operations
with polynomials (simplifying, degree, synthetic division...), exponential expressions, fractions and roots
(radicals), absolute values)
- factoring and expanding expressions
- finding LCM and GCF
-
(simplifying, rationalizing complex denominators...)
- solving linear, quadratic and many other equations
and inequalities
(including basic logarithmic and exponential equations)
- solving a system of two and three linear equations
(including Cramer's rule)
- graphing curves (lines, parabolas, hyperbolas, circles,
ellipses, equation and inequality solutions)
- graphing general functions
- operations with functions (composition, inverse, range, domain...)
- simplifying logarithms
- basic geometry and trigonometry
(similarity, calculating trig functions, right triangle...)
- arithmetic and other pre-algebra topics
(ratios, proportions, measurements...)
ORDER NOW!
|
|
|
|
Algebra Helper
Download (and optional CD)
Only $39.99
|
Click to Buy Now:
OR
|
|
|
|
|
|
2Checkout.com is an authorized reseller
of goods provided by Sofmath
|
|
|
|
|
"It
really helped me with my homework. I was
stuck on some problems and your software walked me
step by step through the process..." |
C. Sievert, KY
| |
|
|
|
Sofmath
19179 Blanco #105-234 San Antonio, TX 78258
|
Phone:
(512) 788-5675 Fax: (512) 519-1805
| | |