Problem #1 (20 points) Write a script in Matlab and save it as .m file with name
ID: 2291018 • Letter: P
Question
Problem #1 (20 points) Write a script in Matlab and save it as .m file with name HW16_1. The script will execute the following tasks a) Let the mathematical function f(x) be defined as f(x)-exp(-0.5x) cos(10x) Use fzero) to find the zero of f(x)@ x0-0.1 b) Find the roots of the following polynomial using roots command g(x)x- 2x3 +x -5 Submit the script as a 'm file. (Note: Script is a list of commands which is different from functions) Problem #2 (30 points) Let the two vectors x & y and the matrix z be defined as follows 2.4 1.2 2.2 4.1 x=| 2.2 |, y=| 1.51,2=12.1-3.2 1.9 3.1 1.2 3.2 1.35 0.35 Write a script in Matlab and save it as m file with name HW16_2. The script will execute the following tasks 1 Enter the vectors x &y; and the Matrix z into the script 2- Evaluate L2-11x112 3- Evaluate L1 x 4- Evaluate Linf xl 5- Evaluate the dot product N-(x,y) 6- Evaluated the angle in degrees between the vectors x & y 7- Evaluate M2lz2 8- Evaluate M1 lz1 9- Evaluate Minf-zoExplanation / Answer
Problem 1.
a:
b:
Problem 2.
1.
2.
L2=norm(x) % Euclidean norm or L2 norm of vector x
3.
4.
5.
N=dot(x,y) % dot product of x and y
6.
costheta= N/(norm(x)*norm(y)); % cos(angle) between x and y
thetaindegrees = acosd(costheta) % angle in degree
7.
M2=norm(z) % M2 norm of matrix z
8.
M1=norm(z,1) % M1 norm of matrix z
9.
Minf=norm(z,inf) % Minf norm of matrix z
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.