Vous êtes sur la page 1sur 2

1

Additional Questions
Question 1
All the three roots of the equation x-13x+6=0 lies between x = -5
and x = 5. Write a script file (a function is not needed), using the for
command and the if command, that would capture all the three
roots in a single row matrix.


Question 2
The equation 0
2
3
sin
2
sin = |
.
|

\
|
|
.
|

\
| x x
has 5 roots between x=0 and
x=10, including x = 0. Write a script file that would locate all five roots
in a single row matrix. Use the for command and the if command.


Question 3
Given the function f(x) = x
2
+ 11x - 4. Write a function [x]=findx(N) that would locate an approximation
of x such that f(x) = N, where N is any positive number. Use the while command and the break
command to protect against infinite looping.
Question 4
Write a function function[y]=location1(x), that locates the positions of all elements of a matrix that lie
between -5 and 5 (i.e. 5 value of element -5). The input matrix can be of any size. The required
positions are contained in a single row vector. (For example, if the input matrix is (


), the
elements whose values lie between -5 and 5 are those in positions (1,2), (1,3) and (2,1). So the output of
the function is [1 2 1 3 2 1].)
(Note: Use two for commands and the if command.)
Question 5
Write a function function[row,col]=location2(x), that locates the positions of all elements of a matrix
that lie between -5 and 5 (i.e. 5 value of element -5). The input matrix can be of any size. The
required positions are contained in two row vectors, one containing the row index, and the other

2

containing the column index. (For example, if the input matrix is (


), the elements whose
values lie between -5 and 5 are those in positions (1,2), (1,3) and (2,1). So the output of the function are
the two row matrices: row = [1 1 2], and col = [2 3 1]).
(Note: Use two for commands and the if command.)

Question 6
The equation ( ) ( ) 0 sin sin = x x has an infinite number of roots
(all positive). Write a function function[y]=search2(a) that finds the
root that is just larger than x = a, where a is any positive number.
Use the while command, and use the break command to protect
against infinite looping.


Question 7
Write a function that would return the area under the Gaussian curve
|
|
.
|

\
|
=
2
exp
2
1
2
x
y
t
from x = 0 to x = a.



Question 8
Write a function that would return the area under the curve of
1 3
2
+ + = x x y from x = p to x =q.