Wikipedia

Search results

Saturday, 4 March 2017

EASY SYNTAX BASED MATLAB QUESTIONS 



1. We use MATLAB to solve an equation 2x + 3 = 0. What is the correct function to call and what is the syntax:
(a) find(‘2 * x + 3’)
(b) roots(‘2 * x + 3’)
(c) solve(‘2 * x + 3’)
(d) solve(‘2 * x + 3’, 0)

2. To calculate the limit lim x -- 2+ [ (x+3/x+4) ]
the correct MATLAB call is:
(a) limit((x + 3)/(x – 4), 2, +)
(b) limit((x + 3)/(x – 4)), 2,+
(c) limit((x + 3)/(x – 4), 2, ‘right’)
(d) limit((x + 3)/(x – 4), 2), right

3. To generate a set of uniformly spaced points for 0 ≤ x ≤ 10 you can write:
(a) x = linspace(0:10);
(b) x = linspace(0:0.1:10);
(c) x = linspace(0, 10, ‘u’);
(d) x = linspace(0, 10);

4. You want to plot two curves y1 and y2 against x. To plot y1 as a red lineand y2 as a blue line, the correct command is:
(a) plot(x, y1, ‘r’, x, y2, ‘b’)
(b) plot(x, y1, ‘r’, y2, ‘b’)
(c) plot(x, y1, “r”, y2, “b”)
(d) plot(x, y1, x, y2), color(‘r’, ‘b’)


5. You want to plot a curve as a dashed blue line. The correct command is:
(a) plot(x, y, ‘b–’)
(b) plot(x, y, ‘b–’)
(c) plot(x, y, ‘b’, ‘–’)

6. To add a title to a graph, the correct command is:
(a) plot(x, y, ‘title–>‘Plot of Sin(x)’)
(b) plot(x, y, ‘Plot of Sin(x)’)
(c) plot(x, y), title(‘Plot of Sin(x)’)
(d) plot(x, y), Title(‘Plot of Sin(x)’)

7. To plot a curve as a red dotted line, the correct command is:
(a) plot(x, y, ‘r’, ‘:’)
(b) plot(x, y, ‘r:’)
(c) plot(x, y, ‘r.’)

8. To create a symbolic function f(t) = sin(t) the best command to use is:
(a) syms t; f = sin(t);
(b) syms t; f = sin(‘t’);
(c) syms t; f = ‘sin(t)’;
(d) a or c

9. To plot a symbolic function f you call:
(a) quickplot( f )
(b) symplot( f )
(c) ezplot( f )      
(d) plot( f, ‘symbolic’)

10. You want to use ezplot to generate a graph of a function f and its second derivative on the same graph. The correct command is:
(a) ezplot( f, diff( f, 2))
(b) subplot(1, 2, 1); ezplot( f ) subplot(1, 2, 2); ezplot(diff( f, 2))
(c) ezplot( f ); hold on ezplot(diff( f, 2))
(d) ezplot( f ); hold; ezplot(diff( f, 2));

11. You want to use ezplot to generate a graph of a function f and its second
derivative in side-by-side plots. The correct command is:
(a) subplot(1, 2, 1); ezplot( f ) subplot(1, 2, 2); ezplot(diff( f, 2))
(b) ezplot(subplot(1, f ), subplot(2, diff( f, 2))
(c) ezplot( f ); hold on ezplot(diff( f, 2))

12. You have created a symbolic function f. To display its third derivative, you
can write:
(a) f’’’’
(b) f’’’’ or diff( f, 3)
(c) derivative( f, 3)
(d) diff( f, 3)

13. The subplot command
(a) Allows you to generate several plots contained in the same figure.
(b) Allows you to plot multiple curves on the same graph.
(c) MATLAB does not have a subplot command.

14. Calling subplot(m, n, p)
(a) Divides a figure into an array of plots with m rows and n columns,
putting the current plot at pane p.
(b) Plots curve n against m in pane p.
(c) Plots curve p at location (row, column) = (m, n)
(d) MATLAB does not have a subplot command.


15. If A is a column vector, we can create the transpose or row vector B by writing:
(a) B = transpose(A)
(b) B = A
(c) B = t(A)
(d) B = trans(A)

16. Suppose that x = 7 and y = –3. The statement x ~= y in MATLAB will generate:
(a) ans = 1
(b) ans = 0
(c) ans = –1
(d) An error

17. To enter the elements 1 –2 3 7 in a column vector, we type:
(a) [1: –2:3:7]
(b) [1, –2,3,7]
(c) [ 1; –2; 3; 7]
(d) [1 –2 3 7]

18. To compute the square of a vector f of data, write:
(a) sqr( f )
(b) f. ^ 2
(c) f ^ 2
(d) square( f )

19. To generate the fourth order Taylor expansion of a function f about the
origin, use:
(a) Taylor( f, 4)
(b) taylor( f, 4)
(c) taylor( f ), terms(‘4’)
(d) taylor, f, 4

20. A function is defined as f = a * x ^ 2 – 2. The command solve( f, a) yields:
(a) 2/a
(b) 2/x
(c) –2/x
(d) An error: rhs must be specified.


21. A variable called y has one row and 11 columns. If we type size(yMATLAB returns:
(a) 11
(b) 1 11
(c) 11 1
(d) (1, 11)

22. To implement a for loop which ranges over 1 ≤ x ≤ 5 in increments of 0.5
the best command is:
(a) for i = 1, 5, 0.5
(b) for i = 1:0.5:5
(c) for loop i = 1, 5, 0.5
(d) loop i = 1:0.5:5 do

23. A function y = exp(-2*x)  is defined numerically for some data range x. It can be entered using:
(a) y = exp(–x) * exp(–x)
(b) y = sqr(exp(–x))
(c) y = exp(–x). * exp(–x)
(d) y = sqrt(exp(–x))

24. To find the largest value in a column vector x, type:
(a) max(x)
(b) maximum(x)
(c) largest(x)

25. The labels used by MATLAB on an x–y plot are specified with:
(a) The labels command.
(b) The xlabel and ylabel command.
(c) The label command
(d) The text command

26. To specify the domain and range used in an xy plot where a <=x <= bc <=y <= d
(a) axis([a b c d ])
(b) axis(a b c d )
(c) axis([a, b, c, d ])
(d) axis a, b, c, d

27. To plot a log-log plot, the correct command is:
(a) plot(x, y, ‘log-log’)
(b) loglog(x, y)
(c) log(x, y)
(d) logplot(x, y)

28. When solving a differential equation using MATLAB, the dsolve command expects the user to indicate a second derivative of y = f(x) by typing:
(a) y’’
(b) diff(y, 2)
(c) D ^ 2y
(d) D2y
(e) D(Dy)

29. To find a solution of
Dy/dt+ 2y = 0
The best syntax to use in MATLAB is:
(a) diff(‘y’ + 2 * y = 0’)
(b) dsolve(‘Dy + 2 * y’)
(c) dsolve(‘Dy + 2 * y = 0’)
(d) diff(Dy + 2y)

30. Who invented MATLAB and when ?
a.Cleve Moler (1987)
b.Jack Little (1992)
c.Cleve Moler (1985)
d.John Little (1987)



No comments:

Post a Comment