Below is an example of how an output of your work for the commands

1

MATLAB PROJECT 4A

GROUP # ___________

FIRST & LAST NAMES:

_1.___________________________________________________________

_2.___________________________________________________________

_3.____________________________________________________________

_4.____________________________________________________________

By signing your names above, each of you had confirmed that you did the work and

agree with the work submitted. 

2

Please follow the instructions below unless a specific requirement on

the submission format is indicated in the exercise. Failure to fulfill the

requirements on the format will result in a loss of points on the Project.

Below is an example of how an output of your work for the commands executed in MATLAB

should look. A page similar to the one below has to be created in MATLAB for each exercise

and called exercise# (please put the corresponding number). The file will be created by using

the command diary exercise#. After the file diary exercise# is initiated, the next command

will be diary on – the beginning of recording. Everything that you put in the Command

Window will be recorded in the created file. The command diary off will end up the

recording. Within the diary file: the command type function name types the function that has

to be previously created using the text editor and saved in MATLAB with the extension .m.

Then you should assign values to the arguments in the function and call the function. Please

refer to MATLAB help page on the subject of creating functions in files:

http://www.mathworks.com/help/matlab/matlab_prog/create-functions-in-files.html

After you got the required outputs, execute the last command diary off and your file is ready

for printing. The printed “diary” file for each exercise has to be turned in as a part of the

Project.

Example of the function “add” placed into a “diary file” and executed:

diary on

type add

function c=add(a,b)

% c=add(a,b). This is the function which adds

% the matrices a and b. It duplicates the MATLAB

% function a+b.*

[m,n]=size(a);

[k,l]=size(b);

if m~=k | n~=l,

 disp(‘ERROR using add: matrices are not the same size’)

 return,

end

c=zeros(m,n);

for i=1:m,

 for j=1:n,

 c(i,j)=a(i,j)+b(i,j);

 end

end

format compact

a=[1 2 3;4 5 6]

a =

 1 2 3

 4 5 6

b=ones(2,3);

c=add(a,b)

c =

 2 3 4

 5 6 7

diary off

*Comments are supplied with % sign – they are not executed in MATLAB.

3

Part I. Eigenvectors & Diagonalization

Exercise4_1a (8 points) Difficulty: Hard

In this exercise, you will find all eigenvalues of a given n n × matrix A. Then you will choose

the distinct eigenvalues and, for each of them, you will find a “rational” basis for the

corresponding eigenspace and the dimension of that eigenspace. Then you will decide whether

A is diagonalizable applying the general theory. If the matrix is diagonalizable, an

OPTIONAL output has to also contain an invertable matrix P and the diagonal matrix D, such

that, 1 A PDP− = , or, equivalently, AP PD = .

You will write a set of commands for an n n × matrix A which will produce the following

outputs. Each output has to be supplied with the corresponding message (you could use the

commands disp or fprintf)

(1) A row vector L (use the command transpose) of all eigenvalues – each eigenvalue repeats

as many times as its multiplicity. You should also use closetozeroroundoff function (the code

is below) to ensure that zero eigenvalues will be the 0’s. The basic MATLAB command for

this part is eig(A) which returns a column vector of all eigenvalues of A.

(2) A row vector M of all distinct eigenvalues (no repetition is allowed). The MATLAB

command unique can be used here, which returns the same values of the array but sorted (in

ascending order) and with no repetition.

(3) The sum of multiplicities Q of all eigenvalues (Q has to be equal to n) with the message:

“The sum of multiplicities of the eigenvalues is Q =” (output Q).

(4) For each distinct eigenvalue, the output has to include a “rational” basis W for the

corresponding eigenspace and its dimension. An appropriate command in MATLAB that

creates a rational basis by using the row-operations is null( , ‘ ‘ r ). (Note: command null( )

creates an orthonormal basis for the null space – use help null command in MATAB for more

information). Within the code for this part, BONUS points can be earned (see (5) and (6)

below).

(5) The total sum N of the dimensions of all eigenspaces with the message: “The total sum of

the dimensions of the eigenspaces is N =” (output N). The value of N has to be compared with

Q (or n) and, based on the comparison, one of the two messages has to be displayed: “Yes,

matrix A is diagonalizable since N=Q” or “No, matrix A is not diagonalizable since N<Q”. If

matrix A is not diagonalizable, the program terminates.

(BONUS! 2 points) If A is diagonalizable output the matrix P whose columns are the bases

for the eigenspaces, which you have calculated above, and the diagonal matrix D with the

corresponding eigenvalues on the main diagonal (you might need to sort the elements of L to

ensure that D would be constructer property – use the MATLAB command sort when

calculating L). Verify that the matrix F=closetozeroroundoff( AP PD ∗−∗ ) is the zero

matrix. If it is the case, the output has to be the message: “Great! I got a diagonalization!”

And, if it is not the case, the output will be the message: “Oops! I got a bug in my code.”

(6) (BONUS! 2 points) display the multiplicity of each eigenvalue in part (4). Compare each

multiplicity with the dimension of the corresponding eigenspace and, if they do not match,

display a message: “Matrix A is not diagonalizable since the dimension of the eigenspace is

less than the multiplicity of the corresponding eigenvalue”.

 

4

A for loop can be used, if needed, along with the MATLAB functions eig, null( ,’r’), size

within your code.

Create a function in MATLAB:

function L = eigen(A)

Please! use the command

format compact (a few blank lines will be printed)

Also, print 2 pages per sheet if possible (it will save a lot of paper!)

Here is a code for closetozeroroundoff:

function B=closetozeroroundoff(A)

[m,n]=size(A);

for i=1:m

for j=1:n

if abs(A(i,j))<10^(-7)

A(i,j) = 0;

end

end

end

B=A;

Run the function eigen(A) on the following matrices

(a) A =

2 2

0 2

 

   

; (b)

Get 20% Discount on This Paper
Pages (550 words)
Approximate price: -

Try it now!

Get 20% Discount on This Paper

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Custom Writings Help is a Quality-Oriented Company in Online Writing as a result of hiring exceptional professionals to execute clients' tasks.

Essays

Research Papers

At Custom Writings Help,We understand the struggle of research paper writing, and that is why at Custom WritingS Help, we are all out to help you. We pride ourselves on having a team of clinical writers. The stringent and rigorous vetting process ensures that only the 'BEST' Writers are chosen for the job. We have highly qualified Ph.D. and MA writers working with us; we equally offer these experienced writers specific bonuses and incentives to make them deliver highly original, unique, and informative content at reasonably low prices.

Admissions

Thesis Writing Service

Worlwide, Many Masters Students are struggling with Thesis Completion. A thesis is likely to be the longest and most challenging piece of work a student has ever completed. However, unlike essays and other assignments, a student can pick a particular interest topic and work on their initiative. Fortunately, we are there for you. At Custom Writings Help, you are assured of an authentic, imaginative, informative, linguistically great, and advantageous thesis that adheres to all your needs. So, why continue considering different writers when you have discovered the best in the field?

Editing

Custom Papers

Not a single student can avoid writing custom papers. However, a total lack of experience, skills, and time makes it very hard to produce a superb writing piece. Therefore, if you are seeking professional help, turn to us. Our specialized and experienced writers compose a variety of model papers, including custom essays, college term papers, research papers, book reports, MBA essays, executive summaries, dissertations, Ph.D. theses, admission essays, and research proposals for college and university students at any level.

Coursework

Essay Writing

Most of the students disregard the critical principles of essay writing and compose papers below sensible guidelines. Therefore, with Custom Writings Help, one should not worry about his/her essay. Our Writers compose informative and engaging content on all complexities and topics. We write meaningful and smart essays while prioritizing all aspects that bring about a good grade, such as impeccable grammar, proper structure, zero-plagiarism, and conformance to guidelines.

Coursework

Coourse Work Writing

Don't let the seemingly never-ending onslaught of writing assignments get you down. If you are looking where to get course work assistance online, the writers at Custom Writings Help are here to assist you with all of your writing needs. We undertake to unique delivery of papers that meet the professor's requirements. The content is proofread, edited, and checked plagiarism before submission to customers. No matter how big or small your work is, we will deliver on time. Try US Now! !

Coursework

Dissertation Writing Service

High-Quality Dissertation Writing Services are rare. They require Ph.D. academicians – not easily found. However, are an exception. The years, time, and resources we have invested in the dissertation world has given us a competitive advantage over others. Choose to come to Custom Writings Help; You will find perfect Ph.D. consultants who have written hundreds of dissertations theses ready to help you. Let our dissertation-writing services help you craft your dissertation, for you are assured we will give you the results.