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

The primary form of data in MATLAB is vectors. They can be one-dimensional (i.e.

ID: 3884564 • Letter: T

Question

The primary form of data in MATLAB is vectors. They can be one-dimensional (i.e., vectors), or two-dimensional (i.e., matrices). a) Write the MATLAB code to create a 1 times 3 vector containing the elements [1, 2, 3]. Additionally, write the MATLAB code to create a 3 times 1 vector with the same elements. b) Write the MATLAB code to create the vector [2, 4, 6, .., 98, 100] and store it in a variable named x. c) Write the MATLAB code to create a 2 times 2 matrix containing the elements [1, 2, 3, 4] (The order of the numbers do not matter). MATLAB has several types of built-in math functions that can help you perform common operations. a) Write the MATLAB code that takes the absolute value of -134. b) Write the MATLAB code that stores a number 3*pi in a variable named x, then takes the cosine of x. c) Functions can also be applied to vectors. Assume you have a vector y, which contains the elements [4, 9, 16]. Write the MATLAB code to take the squareroot of y. What should the result be?

Explanation / Answer

onebythree=[1 2 3] %1(a)

threebyone=[1;2;3] %1(b)

x=2:2:100 %1(c)

mat=[1 2; 3 4] %1(d)


absolute=abs(-134) %2(a)

x=3*pi
cosineofx=cos(x) %2(b)


y=[4 9 16]
answer=sqrt(y) %2(c)

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