VIEWS: 1 PAGES: 2 POSTED ON: 12/20/2011
Weizmann 2011-2012 Introduction to Matlab & Data Analysis Exercise #1 E-mail for submission and questions: email@example.com Please read the submission guidelines (in the course website) carefully, before doing the task. Question 1: simple display 1. Write your name into the variable myName. 2. Display myName to the screen. 3. Pause for 0.3 seconds 4. Display your favorite movie quote. 5. Pause for 0.3 seconds. Question 2: matlab questions Note: some of matlabs functions display text on the screen (regardless of semi-colon). In these cases don‟t try to use the disp command. 1. Write your age into a variable called „myAge‟. 2. Display the following „my age is <myAge>‟. You must use matlab sprintf command in order to display complex input (contains both numeric and text). 3. What is the difference between the who,whos commands ? What is the output of both of them in your pc? 4. List MATLAB files in folder using matlab specific function(find out which one). 5. This ex is annoying. Ask matlab why (repeat it 5 times)… 6. Repeat section 5 two more times. Question 3: matrix manipulations Please read matlab‟s introduction to matrices 1. Create the variable „n‟ with a value of 5. 2. Create a matrix with n rows and n columns that is a magic square ( = equal row, column, and diagonal sums). 3. Let‟s check that this is a magic square . Display the column-wise and row- wise sum of M. 4. Flip the matrix left to right (first column become last etc…). Weizmann 2011-2012 Introduction to Matlab & Data Analysis 5. M is a 2-D matrix with a size of 5X5. Each entry has two coordinates, row and column. Display the content of M in the 3rd column, 4th row, using double index (two coordinates). 6. In matlab you can refer M as a 1-D matrix in length of 25. Just access it with a single index ( one coordinate). What single index is equivalent to the double index in the previous question? What is the general formula for this conversion? (in terms of i,j,m,n : (i,j) – the double index in a mXn matrix ). 7. The indices (1,1),(2,2),(3,3)… are the indices that are on the diagonal. Create a vector d that is the single index representation of those diagonal indices (with the command: d=a:b:c, figure out which a,b,c will fit here). 8. Compute the sum of elements that are on the diagonal, using d, and display it. 9. Assign the value 3 to the first row, only columns 3,4,5 (use the colon operator). 10. Assign the value 2 to all the second column (use the colon operator) . 11. Remove the 5th row from M. 12. Assign the variables m = #matrix rows ,n=#matrix columns. Don‟t type it explicitly but use matlab function that returns the matrix size. Display the new matrix size: “The new size of M is mXn” using sprint. Of course you must replace the characters m,n with their value. 13. Display the size of M using sprintf:. Don‟t just write 4X5, but enter the variable 14. Compute the mean of the columns of M and display it. The answer is a matrix with size of 1X5 15. Matrix multiplication: - it is possible only if the number of columns in B is equal to the number of rows in C. A has the same rows number as in B and the same columns number as in C. The formula is . Repeat the same as in 14, but this time do it through matrix multiplication – find the other matrix that is required that will yield the same result as in 14 (hint: the result A is a matrix with the same columns number as M, so M is the matrix from the right – so you must find the matrix from the left).
Pages to are hidden for
"HW1"Please download to view full document