MATLAB essential/Quiz 1: Lecture 1 + Lecture 2

'''You can refer to the previous lectures or even use Google while taking this quiz. Do NOT use MATLAB while taking the quiz. The point of this quiz is to make sure that you understand what was covered so far, by using MATLAB, you are cheating yourself.'''

This quiz will contain questions about the material covered in the first two lectures ( general information + arrays + how to solve equations ). The first few questions ask you to write a short pieces of code. The answers are in a google document. Once you finish the quiz @undefined and I will give you a link to the document. The second set of questions are multiple choice, and complete the statement. The answers for these question will be shown after you submit your answers. If you have any questions please do not hesitate to @undefined.

complete the text, True or False, and multiple choice
{Complete the text: By looking at figure#1, click on image to see full size, window number one is the { editor (i) }, number 2 is the { command window (i) }, and window number three is { workspace (i) }.
 * type="{}"}

{Complete the text: The keyword for integration is { int (i) } and the keyword for differentiation is { diff (i) }
 * type="{}"}

{Complete the text: When defining a variable in MATLAB, the keyword { syms (i) } must be used
 * type="{}"}

{Complete the text: The command { help (i) } is used whenever you want to know more information about a certain function command using MATLAB command window.
 * type="{}"}

{Which of the commands below you use to define this function $$f(x)= \tfrac{e^x}{x} + \sqrt{x}$$ :. - TRUE + FALSE
 * type=""}

{True or False, The percent sign (%) in used to suppress the outcome of a piece of code.
 * type=""}

- TRUE + FALSE

{Which of the commands below you use to define this function $$f(x)= \tfrac{e^x}{x} + \sqrt{x}$$ :. - f=(x) exp(x)/x + sqrt(x) - f=@(x) exp^(x)/x + sqrt(x) - f=@(x) e(x)/x + sqrt(x) - f=(x) exp(x)/x + sqrt(x) + f=@(x) exp(x)/x + sqrt(x)
 * type=""}

{Choose the right answer. Which one of these matrices will be create with this MATLAB code : B=[ 1 2 3 ; 3 2 1 ] :.
 * type=""}

- B= \begin{bmatrix} 1 & 1 \\2 & 2 \\ 3 & 3 \end{bmatrix} + B= \begin{bmatrix} 1 & 2 & 3 \\1 & 2 & 3 \end{bmatrix}

Write MATLAB code
Question 1

Using MATLAB, write any two matrices that when added together using MATLAB yield the following matrix A= $$\begin{bmatrix} -4 & 2.5 & 0 \\20 & 5 & 1 \end{bmatrix}. $$  A=[-4,2.5,0 ; 20, 5, 1] D=[1,1,1 ; 1,1,1] A-D ans =

-5.00000   1.50000   -1.00000   19.00000    4.00000    0.00000 ans+D ans =

-4.00000   2.50000    0.00000   20.00000    5.00000    1.00000

Question 2 Using MATLAB, write any two matrices that when subtracted together using MATLAB yield the following matrix: B= $$\begin{bmatrix} 1 & -13 & 8 \\40 & 50 & 10 \end{bmatrix}. $$ B=[1,-13,8 ; 40, 50, 10] C=[1,1,1 ; 1,1,1] B =

1 -13    8   40   50   10

C =

1  1   1   1   1   1 C-B ans =

0  14   -7  -39  -49   -9 C-ans ans =

1 -13    8   40   50   10

Question 3

What is the function of (%), (@), and symbols. % to write a comment with no action @ to difine a function Question 4
 * to separet betwen 2 row in matrix

Briefly describe the difference between Command window and Editor. Editor you can fix the code & you can save work in a M-file in Window you can not safe work or fix code but you can use to write a smale code and erase.

Question 5

If you have the following equation: $f(x)= e^x + sin(5x)$. You want to find the solution of this equation using MATLAB. How do you express this function in MATLAB syntax ? f=@(x) exp(x) + sine(5*x)

Question 6

Write a MATLAB code to differentiate the following function twice:

$$e^x\sqrt{sinx + cosx}$$ syms x w=exp(x)* sqrt(sin(x)+cos(x)) diff(w,2) Question 7

Write a MATLAB function to partially differentiate the following function with respect to y:

$$z(x,y)= e^y+sin(xy)cos(yx)$$ syms x y z z=exp(y)+ (sin(x*y)*cos(x*y)) diff(x,y)

Question 8

Write a MATLAB code to integrate the following function from 1 to infinity:

$$\int (log(x))^2$$ int ((log(x)^2),1,inf)

Question 9

write the code to find the anwer of the follwing equation using using MATLAB

$$\lim_{x \to \infty} \frac{x}{sin(x)} = L$$ limit (x/sin(x),x,inf)

Question 10

The code below will give an error, why? and how can you fix it ? DO NOT USE MATLAB.

x=[11,24,32 ; 21 32 43 ] y=[25 31 42; 26 37 48] x*y 1st there is no betwen the 2nd row of x matrix & betwen the 1st&2nd row of y matrix 2nd x matrix size is 2*3 then y matrix shold be for exampel 3*inf in isted of 2*3.