Roll No. .........................
Total Pages : 6 (g) What is the difference between Numeric (plain
MATLAB) and Symbolic (the Symbolic Math
CMDE/M-24 4671 Toolbox) computation?
COMPUTER PROGRAMMING WITH (h) How to create M-file.
MATLAB
UNIT–I
Paper–MMATH20–202
2. (a) Write a MATLAB command to compute following
Time Allowed : 3 Hours] [Maximum Marks : 80 mathematical operations : 4×2=8
(i) tanh(e) (ii) log102.
Note : Attempt five questions in all, selecting one question
from each Unit. Question No. 1 is compulsory. All (iii) 123456 mod 789. (
(iv) Arg 1 + i 2 .)
questions carry equal marks. (b) (i) Write a MATLAB script file to create a row
vector with 9 equally spaced elements in which
Compulsory Question
the first element is 81 and element is 12. 4
1. Answer the following questions : 8×2=16
(ii) Write a MATLAB function file to create a
(a) Write any two advantages of MATLAB Software. column vector that has the following
y
(b) What is a command Window? elements y, y x , ln , y ⋅ x, and x + y where
x
(c) Distinguish between Array multiplication and Matrix x = 0.85, y = 1.25. 4
multiplication. 3. (a) Discuss the role of following files, 4×2=8
(d) What is the purpose of Data files? (i) M-file. (ii) Mat-file.
(e) Give any two advantages of Cell array in MATLAB (iii) Fig-file. (iv) P-file.
programming. (b) Define a following MATLAB commands for any
integer m, n : 8×1=8
(f) Distinguish between Plot and Stem.
(i) rand (ii) rand(l,n)
4671/K/354/200 P. T. O. 4671/K/354/200 2
(iii) rand(n) (iv) rand(m,n) UNIT–III
(v) randperm(n) (vi) randi(imax) 6. (a) Write a script file to plot the function
y = 3x3 − 26x +10 ; [ −2, 4] using following commands :
(vii) randi(imax,n) (viii) randi (imax, m,n)
(i) plot command
UNIT–II
(ii) hold on and hold off commands.
4. (a) Define a following MATLAB command with an
example : 4×2=8 (iii) line command
(i) For loop (ii) While loop (iv) fplot command. 4×2=8
(iii) If-elseif-else (iv) Return. (b) (i) Define a three different ways of generating
overlay plots in MATLAB. 4
(b) Write a MATLAB code for printing the prime numbers
below 50 and also write a note on accessing elements (ii) Write a MATLAB script file to generate an
from a cell array with examples. 8 overlay plot with hold command for 4
y ( x) = sin x, x ∈ [ 0, 2π] .
5. (a) (i) List some differences between a script file and
a function file. 4 7. (a) Discuss various commands to use 2-D plots in
MATLAB. 8
(ii) Write MATLAB function file to find area of
Circle. 4 (b) Write a MATLAB script file to plot
x = t , y = et , t ∈ [ 0, 2π] using following commands :
(b) (i) Write a MATLAB function file factorial to sum
of a Geometric series : 4 (i) Semilogx
1 + r + r 2 + .... r n , for any integer n. (ii) Semilogy
(ii) Write a function factorial to compute the factorial (iii) Loglog
n!, for any integer n. 4
(iv) Plotyy. 4×2=8
4671/K/354/200 3 P. T. O. 4671/K/354/200 4
UNIT–IV (b) (i) Write the MATLAB script file to solve the
following system of linear equations : 4
8. (a) Define x as a symbolic variable and create the two
symbolic expressions : 4×2=8 3x1 − x2 + 2 x3 = 7
S1 = x 2 ( x − 6) + 4(3x − 2) and S2 = ( x + 2) 2 − 8 x x1 + x2 + 2 x3 = 9
2 x1 − 2 x2 − x3 = −5
Use symbolic operations to determine the simplest
form of each of following expressions : (ii) Write a MATLAB script file to compute
S1 sin x + cos x + 1 series. 4
(i) S1 . S 2 (ii) S2
(iii) S1 + S2
(iv) Use the subs command to evaluate the numerical
value of the result from (iii) for x = 5.
(b) Define x as a symbolic variable. 2×4=8
(i) Derive the equation of the polynomial that has
the roots x = –2, x == –0.5, x = 2 and x = 4.5.
(ii) Determine the roots of the polynomial
f ( x) = x6 − 6.5x5 − 58x4 +167.5x3 + 728x2 − 890x −1400
by using the factor command.
9. (a) (i) How do we create the Symbolic variables and
explain with suitable examples? 4
(ii) Explain the commands used to change an existing
symbolic expression with examples. 4
4671/K/354/200 5 P. T. O. 4671/K/354/200 6