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

PROBLEMS 2.1 What is the output when the following commands are 2.8 The command

ID: 1838985 • Letter: P

Question

PROBLEMS 2.1 What is the output when the following commands are 2.8 The command 1inspace(a, b, n) generates a row vec- and b. Use colon tor of n equally spaced points between a notation to write an alternative onc-line command to gener- ate the same vector. Test your formulation for a-3,b A,3)-[1 A [A(:,1) [4 5 7] A(:,2)] A- sun(diag(A)) 2.2 You want to write MATLAB equations to compuie a (a) Write out the resulting matrix. vector of y values using the following equations 2.9 The following matrix is entered in MATLAB 3 2 1:0:0.5:1;inspace(6, 8, 3)] (b) Use colon notation to write a single-line MATLAB command to multiply the second row by the third col- umn and assign the result to the variable c. 8 sin(5r) (b) va4.a 2.10 The following equation can he used to compute values of y as a function of x where r is a vector. Make sure that you use periods only where necessary so the equation handles vector operations ybe properly. Extra periods will be considered incorrect. 2.3 Write a MATLAB expression to compute and dis- play the values of a vector of x values using the following equation sin(bx)(0.01 where a and b are parameters. Write the equation for imple- mentation with vector holding values from 0 to ?/2 in increments of Ax = x/40. Employ the minimum number of periods (G.e., dot no- tation) so that your formulation yields a vector for y. In ad- MATLAB, where a 2, b-5, and is a Assume that y and z are vector a and b are scalars quantities of equal length and dition, compute the vectior y where each element holds the square of each element of y. Combine x, y, and z into 2.4 What is displayed when the following MATLAB state- a matrix w, where each column holds one of the variables, ments are executed and display w using the short g format. In addition, gener- ate a labeled plot of y and z versus x. Include a legend on the plot (use help to understand how to do this). For y, use a 1.5-point, dashdotted red line with 14-point, red-edged, (a) A=[1 2; 3 4; 5 6]; A(2.). (c) a#2; b-8; c.4; a + b / c 2.5 The MATLAB humps function defines a curve that has white-faced pen 2 maxima (peaks) of unequal height over the interval0sas2, dard-sized (i.e., default) solid blue line with standard-sized, tagram-shaped markers. For z, use a stan- blue-edged, green-faced square markers. 2.11 A simple electric circuit consisting of a resistor, a ca- Cx-0.3)+0.0 0.9) +0.04 MATLAB to generate a plot of f(x) versus r with pacitor, and an inductor is depicted in Fig. P2.11. The charge x [0:1/256:2]; Use on the capacitor qlu) as a function of time can be computed as periods esperm the vectoropera ens needled to generate Do not use MATLAB's built-in humps function to gencrate the values of fx). Also, employ the minimum number of 40=wen?, cos Vi - LC fx) values for the plot. 2.6 Use the linspace function to create vectors identical to the following created with colon notation: (a) t# 4:635 (b) x=-42 2.7 Use colon notation to create vectors identical to the following created with the linspace function: where t- time, go the initial charge, R the resistance, L- inductance, and C= capacitance. Use MATLAB to generate a plot of this function from -0 to 0.8, given that go-10, R-60, L-9, and C 0.00005. 2.12 The standard normal probability density function is a bell-shaped curve that can be represented as (a) v=linspace(-2,1·5,8) (b) r= linspace(8,45,8)

Explanation / Answer

2.1 output is as follows.

A =

1 2 3
2 4 6
3 2 1

A =

1 2 3
2 4 2
3 6 1

A =

1 2
2 4
3 6

A =

1 4 2
2 5 4
3 7 6

A =

12

2.2 (a)

t=[1:.1:10];
y=(6*t.^3-3*t-4)./(8*sin(5*t));

"." is the periods used in the equation for vector operation.

2.2. (b)

t=[1:.1:10];
y=(6*t-4)./(8*t)-pi()*t/2;

2.3

y=[5:.1:10];
z=[5:.1:10];
a=5;
b=6;
x=(y.*(a+b*z).^1.8)./(z.*(1-y)) ;

2.4 (a)

ans =

3
4

2.4 (b)

y =

0
1.5000
3.0000
4.5000
6.0000

2.4 (c)

ans =

4

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