Your Algebra Homework Can Now Be Easier Than Ever!

MATLAB Project # 0 - HOMEWORK IN

MATLAB Project # 0 - HOMEWORK INSTRUCTIONS

This project teaches you how to use MATLAB and present homework . There are two important kind
of les that we will be using throughout the course in the MATLAB Projects: the M-files and the diary
files. The M- files are text les that you can create with a text editor, and they contain commands to be
interpreted by MATLAB. An example of an M- file to solve Problem 1 of this project is the following.

% Solution to
% MATLAB Project 1
% problem 1

format compact

% this command eliminates unnecessary blank lines
% from the output

% We first enter the matrices A and B
A = [1, -2, 3; 4, 5, 6; 7, 8, -10]
B = [-1, 7, 2; -5, 6, 1; 7, -8, 11]

% Now we compute A+B and 3*A
A+B
3*A

% As you already noticed, the symbol % is used to add comments .

An important aspect of M- files is that their names must end with ".m". For the M- file shown in the
example, I would use the name p0prob1.m, but you can use the names you like! When you want MATLAB
to follow the instructions in the M- file, you must type the filename without the extension .m in the MATLAB
prompt, and you have to be working in the directory where the le is stored. To go to a directory we use
the cd command. This will be better understood with an example: Suppose that the le p0prob1.m is in
the directory c:nmath461nmatlab, then to run the script in that le you have to type the following:

>> cd c:\math461\matlab
>> p0prob1

and MATLAB will output

The diary files are text les where MATLAB stores all what you see on the screen as you run commands
and/or invoke M- files. Suppose that now we modify p0prob1.m adding the line diary p0prob1.txt at the
beginning and the line diary off at the end. Then, as a result, when you invoke p0prob1 at the MATLAB
prompt, MATLAB will show on the screen the same as before, but at the same time, it will save that
information on the le p0prob1.txt. If the diary file already existed, MATLAB would append the lines at
the end.

You will have to use the diary files to hand in the MATLAB projects. Since I will want the diary files
to contain the commands used in the M- files for performing the required task, you will have to include the
line echo on at the beginning of the le.

Here is a summary of the steps used to prepare homework solutions.

(1) Create an M-file in your current working directory to hold the solution. Include echo on near the
top of the le so you can see which commands are producing what output when you run the M- file.

(2) Continue editing and running the M- file until you are con dent that it contains the MATLAB
commands that solve the problem .

(3) Add comments to your M- files to explain the method being used to solve the problem and to
interpret the results.

(4) If you didn't do so before, insert the delete and diary commands into the M- file (see example
below).

(5) Now run the M- file to produce the final solution. Send the diary file to the printer. Collect the
pages, staple them together and submit them.

To illustrate the results of this process, here is the final version of the M- file for problem 1.

file p0prob1.m

delete p0prob1.txt % we delete the file just in case it existed
diary p0prob1.txt
format compact
echo on

% Solution to
% MATLAB Project 1
% problem 1

% We first enter the matrices A and B
A = [1, -2, 3; 4, 5, 6; 7, 8, -10]
B = [-1, 7, 2; -5, 6, 1; 7, -8, 11]

% Now we compute A+B and 3*A
A+B
3*A

% The results MATLAB gave for A+B and 3*A agree with our definitions
% for adding matrices and multiplying by scalars .

echo off
diary off
% it is important to do this, otherwise MATLAB would
% continue to add lines to the diary file

And the diary file p0prob1.txt will look like

file p0prob1.txt

% Solution to
% MATLAB Project 1
% problem 1

% We first enter the matrices A and B

% Now we compute A+B and 3*A
A+B

% The results MATLAB gave for A+B and 3*A agree with our definitions
% for adding matrices and multiplying by scalars .

echo off

Final Note

Each problem should be worked in a separate M- file, and the results saved in a diary
file. A printout of the diary file should be handed in. Use comment lines in your M- file
to make appropriate comments and to indicate the problem number . Use the echo
command to display the commands in your M- files in the command window, and thus
in the diary file.

Try the following 4 problems to practice both MATLAB commands and diary files. You will need both
for MATLAB Project # 1, which will be graded.

Problem 1: Enter the matrices

and

Compute A + B and 3A. Do the results agree with our definitions for adding matrices and multiplying
matrices by scalars?

Problem 2: Enter the matrices

and

Compute A+B, A+C, C +B. Do the results agree with our definitions for adding matrices? Why, or why
not?

Problem 3: Enter the vectors (column matrices)
 

and

Then compute the linear combinations 2u + 3v and 3u - 12v.

Problem 4: Enter the matrices

and

Then compute x ยท y by forming the matrix product x '*y. Explain why this matrix product gives the correct
answer. What does the prime do? What happens if we type x*y? why? What is the result of typing x*y'?

Problem 5: Let

and

(a) Compute AB and BA, using matrix multiplication in MATLAB. Are they the same? Did you expect
them to be the same? Explain.
(b) Compute (AB)C and A(BC). Are they the same? Did you expect them to be the same? Why?

Prev Next

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 March 29th 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
Check out our demo!
 
"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
 

Home   : :   Features   : :   Demo   : :   FAQ   : :   Order

Copyright © 2004-2024, Algebra-Answer.Com.  All rights reserved.