Reference no: EM132262725
Question 1:
Write a function that takes in as input, two vectors, say, x_ and y_ of any length n. Your output should be the dot product x_·y_. The first line of your function should look like
function vecproduct = dot (x , y )
Question 2:
Write a function that takes in as input, a vector, say x_. Your output should then be a vector containing the norm 1, norm 2 and norm infinity of the vector in the specified order, denoted respectively as ||·||2, ||·||2 and ||·||∞. The first line of your function should look like
function [ norm1 norm2 norminf ]=norm( x )
Question 3:
The Lab questions below are from Chapter 2.
We will begin with a very simple one. Write a function that takes a square matrix, say A, that is odd as an input. This function must add up the edge elements of the matrix, and then multiply the answer obtained with the middle column vector of the matrix. The first line of your function should look like:
function Ans= MatrixFun (A)
Question 4:
Write a function that takes in a non-negative integer n as an input. The function must generate a matrix of size n × n, where all the values in the matrix are zero except for those in the diagonal. The diagonal entries satisfy the relation aii = i. The output matrix when n = 4 looks like:
The first line of your code should look like:
function A= MatrixDia (n)