正在加载图片...
Homework 12 for MATLIB(Due:11:00 pm March.8) 1.Array manipulation Create a function a diagAndEdgeFilled (n) to create a n by n matrix called"a"that is zero everywhere except for ones in the first column and last column and ones in the first row and last row.There are also ones on the main diagonal of the matrix,(a(i,i)=1)for all i.Do it the MATLAB way!You should not use any iteration statement like for or while,otherwise,one point will be deducted for every iteration command you have used. 2.Matrix rotation and flipping Write 4 different functions that: Rotates a matrix in a clockwise fashion Rotates a matrix in a counterclockwise fashion Flips a matrix about its horizontal mid-line Flips a matrix about its vertical mid-line Hints and instructions. Recall that [Rows,Columns]=size(a)can be used to get the number of rows and columns of the matrix a Your functions have to work on arrays of any size Your functions do not have to provide output to the help and look for functions. Here's some sample output: >>a=rand(2,3) a Once again,you should not use any iteration 0.9218 0.1763 0.9355 command in those four functions. 0.7382 0.4057 0.9169 3.Redo the last homework 2. >disp(rotateClockWise(a)) From last homework,some of you have identified that 0.7382 0.9218 there are two roots for the function,you will get only 0.4057 0.1763 one of them depending on you initial guess.This time, 0.9169 0.9355 you are going to redo it so that it can take a vector >disp(rotateCounterClockWise(a)) containing two initial guess and get two vectors out 0.9355 0.9169 for x values and iteration steps respectively. 0.1763 0.4057 0.9218 0.7382 Hint:There is some tricky part on this assignment. >disp(flipVertical(a)) Because the iteration steps of the two guess will not 0.9355 0.1763 0.9218 be the same,which make the program much more 0.9169 0.4057 0.7382 challenge and interesting.Once you found a solution >disp(flipHorizontal(a)) for one initial guess,you should not iterate on that one 0.7382 0.4057 0.9169 anymore,you can use the following command identify 0.9218 0.1763 0.9355 the current workItemList-indices for those items you still should work on. workItemList find (abs (y(x))>=epsilon) Again,you need only to turn in the second part of the assignment as a single functionHomework 12 for MATLIB (Due: 11:00 pm March. 8) 1. Array manipulation Create a function a = diagAndEdgeFilled (n) to create a n by n matrix called “a” that is zero everywhere except for ones in the first column and last column and ones in the first row and last row. There are also ones on the main diagonal of the matrix, (a(i, i) = 1) for all i. Do it the MATLAB way! You should not use any iteration statement like for or while, otherwise, one point will be deducted for every iteration command you have used. 2. Matrix rotation and flipping Write 4 different functions that: • Rotates a matrix in a clockwise fashion • Rotates a matrix in a counterclockwise fashion • Flips a matrix about its horizontal mid-line • Flips a matrix about its vertical mid-line Hints and instructions. • Recall that [Rows, Columns] = size(a) can be used to get the number of rows and columns of the matrix a • Your functions have to work on arrays of any size • Your functions do not have to provide output to the help and look for functions. Here’s some sample output: Once again, you should not use any iteration command in those four functions. 3. Redo the last homework 2. From last homework, some of you have identified that there are two roots for the function, you will get only one of them depending on you initial guess. This time, you are going to redo it so that it can take a vector containing two initial guess and get two vectors out for x values and iteration steps respectively. Hint: There is some tricky part on this assignment. Because the iteration steps of the two guess will not be the same, which make the program much more challenge and interesting. Once you found a solution for one initial guess, you should not iterate on that one anymore, you can use the following command identify the current workItemList – indices for those items you still should work on. workItemList = find (abs (y(x)) >= epsilon) Again, you need only to turn in the second part of the assignment as a single function
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有