$35
Please read the file, “How to complete and upload the solution template” before you begin. Download assign1.m and fill it in and then upload the completed file on D2L drop-‐box for Assignment 1. Also download test_assign1.m and assign1_solutions.mat to test your answers as you go. Make sure your name and UCID are correctly filled out in the assign1.m file (you won’t get a mark otherwise.
This, and all subsequent assignments, are marked by an auto-‐checker. Thus, ensure you do not initialize input variables (like 𝑥) yourself; read the code and notice that inputs are always initialized by the code at the top so the auto-‐checker can test your code with different input values. Please follow the solution template to ensure the auto-‐checker doesn’t crash – especially do not change anything outside of the question functions. Any deliberate attempts to crash the auto-checker using malicious code will be considered academic misconduct and will be reported to the Associate Dean (Student Affairs). The auto-‐checker will also check for plagiarism and copying an
assignment will be considered academic misconduct and will be reported to the Associate Dean (Student
Affairs).
Note the assignment questions refer to variable Q, but this will not usually be assigned in your function call; just use the return variable “answer =”.
Note that when you it says “given x=0.2” that literally means x has been set to 0.2 in the code already and you will work with x as a variable name. (The solutions that have been provided use x=0.2 but the auto-‐checker will use a different value of x to check your work.) This is in fact the case for all numbers given in the Chapter 1 questions – use the variable names in your calculations. All angles are in radians.
Questions from Chapter 1
1. Given 𝑥 = 0.2 calculate the following expression: 𝑄 = 5 𝜋*.+ cos 𝑥 * 𝑒0.
2. Given 𝑥 = 0.2 and calculate the following expression: 𝑄 = ln 𝑒 − tan 𝑥 *.
3. Given 𝑥 = 1.5 and 𝑦 = 0.5 compute 𝑄 = cos (9<:;)
4. Given 𝑥 = 8.3 and 𝑦 = 2.4, evaluate
𝑄 = 𝑥* + 𝑦* − :9;;.
5. In question 4 assume that 𝑦 = 2𝑥. Find 𝑄 given 𝑥 = 2.1.
6. Given 𝑥 = 2 and 𝑦 = 3, find the solution of A x B xy Q A= 2, = 2, = tan( )B .
7. The equation that identifies the response of a particular circuit is
𝑅 𝑅 * 1
𝑄 = − + −
2𝐿 2𝐿 𝐿𝐶
Determine the value of 𝑄 for 𝑅 = 800Ω, 𝐶 = 1𝜇F and 𝐿 = 1𝑚H.
8. The number of combinations Q of taking 𝑟 objects out of 𝑛 objects is given by Q= n! .
r n r!( - )!
Determine the number of combinations of taking 2 cards from a deck of 52 cards. Use the built in function factorial.
9. The current 𝑄 (in amps) 𝑡 seconds after closing the switch in a series RL circuit is
𝑄 = M 1 − 𝑒OPQR.
N
Given 𝑉 = 120 volts, 𝑅 = 240Ω and 𝐿 = 0.5 henrys, calculate the current 0.003 seconds after the switch is closed.
10. The formula for changing the base of a logarithm is:
𝑙𝑜𝑔W 𝑁 = YZ[YZ[\\ ]W.
Calculate 𝑄 = log_ 0.085 using Matlab’s log 𝑥 function.
Questions from Chapter 2
0*
0.*;
12. Create a row vector 𝑄 in which the first element is 3 and the last element is 38, with an increment of 5 between the elements as (3,8,…,38).
13. Define the variables 𝑥 = 0.5 and 𝑦 = 1 and generate a 3x3 diagonal matrix 𝑄 with diagonal values of 𝑥, sin 𝑥𝑦 and tan :9. Use the function diag() for this purpose
14. Use the eye command to create a 4x4 identity matrix
1 0 0 0
𝑄 =0 1 0 0.
0 0 1 0
0 0 0 1
15. Form a 3 2´ matrix 𝑄 with the columns of (1,1,1) and (2,2,2).
16. Create the following matrix,
é1 0 3ù êê1 0 4úú
Q=ê1 0 5ú ê ú ê1 0 6ú
êë1 0 7úû
by using linspace, zeros, ones and the transpose operator. Do not type in the individual elements explicitly.
NOTE: You may transpose a vector/matrix using transpose([x y]) or a single quote [x y]’
17. Create the following matrix 𝑄 given as é1 2 3 4 5 6ù
Q=êê7 8 9 10 11 12úú êë13 14 15 16 17 18úû
From this create the following variable:
Create a six element row vector named X that contains the elements of the second row of 𝑄.
18. Using zeros, and ones commands create the following matrix
1 1 1 1
𝑄 =0 0 0 0
0 0 0 0
1 1 1 1
19. Given matrices 𝑋 = and 𝑌 = 0 0 , create the matrix 𝑄 such that
0 0
𝑄 = [𝑋 𝑌].
20. Base on the matrices 𝑋, 𝑌 in question 19 create a matrix 𝑄 such that
𝑄 = 𝑋 𝑌 .
𝑋 𝑌