Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a MATLAB function, called vectornorm that computes the 2-norm of a vector

ID: 2246922 • Letter: W

Question

Write a MATLAB function, called vectornorm that computes the 2-norm of a vector x^vector. The function header should look like this: function norm = vectornorm(x) Show your results for the following vectors: x^vector = (1, 1, 1) x^vector = (1/Squareroot 2, 0, 1/Squareroot 2) x^vector = (0, 0.01, 0.02, 0.03, 0.99, 1) Plot the sine and cosine functions on the same graph in Matlab, to the following specifications: middot The meshwidth should be h = 0.0001. The area shown should be -4 lessthanorequalto x lessthanorequalto 4 and -2 lessthanorequalto y lessthanorequalto 2. (You may have cause to use the ylim command.) The plot of the sine function should consist of a solid blue line with linewidth 2. The plot of the cosine function should consist of a solid red line with linewidth 2. (You will have cause to use the 'linewidth' option when plotting, and the line specifications '-b' and '-r'). Label the axes "x" and "y" (You will have cause to use the xlabel and ylabel commands). Include a legend in your plot-use the legend command.

Explanation / Answer

5

function norm = vectornorm(x)
    x = x.*x; %square each elements of the array
    norm = sqrt(sum(x)); %sum them and find square root
end

Bro you are allowed to post only 1 qustion at a time. Due to certain restriction from chegg, am only answering 1 question as of today...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote