0% found this document useful (0 votes)
28 views6 pages

Matlab Midsem Questions

Matlab trial questions trials

Uploaded by

bharon4business
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views6 pages

Matlab Midsem Questions

Matlab trial questions trials

Uploaded by

bharon4business
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

MIDSEM

Problem 1
a. >> for full version
EDU > for educational version
b. i. Clear the command window
ii. To abort a Matlab computation
c. The help command searches for an exact function name match, while the lookfor
searches the quick summary information in each function for a match.
d. Matlab calculates the angle in radians
Problem 2
t=pi/2;
p=-3;
y=10;
k=(((sin(5*t)/(2*p))-(cos(t)/(p^3)))/(y^2))+((log10(6*t))/(p^-3))

k =

-26.3070

Problem 3
h=-2:3:10

h =

-2 1 4 7 10

m= linspace(1,10,10)

m =

1 2 3 4 5 6 7 8 9 10

b.i. det(A)
ii. inv(A)
iii.eig(A)
iv.rank(A)

Problem 4
n=input('Enter vector corresponding to a,b,c,d :')
roots(n)

Enter vector corresponding to a,b,c,d :[3 0 -4 1]

n =

3 0 -4 1
ans =

-1.2638
1.0000
0.2638

OR

n1=input('Enter value of a :')


n2=input('Enter value of b :')
n3=input('Enter value of c :')
n4=input('Enter value of d:')
n=[n1 n2 n3 n4]
roots(n)

Enter value of a :3

n1 =

Enter value of b :0

n2 =

Enter value of c :-4

n3 =

-4

Enter value of d:1

n4 =

n =

3 0 -4 1

ans =

-1.2638
1.0000
0.2638
Problem 5
function [d]=kjjj(x)
d=x^2+(109.3*x^1.35)-20000;
end

x0=0;
fzero(@kjjj,x0)
Exiting fzero: aborting search for an interval containing a sign change
because complex function value encountered during search.
(Function value at -0.0282843 is -20000.4022-0.790836649i.)
Check function or try again with a different starting value.

ans =

NaN

Problem 6
A=[-2 3 1;4 1 1;1 -1 3]

A =

-2 3 1
4 1 1
1 -1 3

[m,n]=size(A)

m =

3
1

n =

A(:,2)

ans =

3
1
-1

A'

ans =

-2 4 1
3 1 -1
1 1 3

A(3,2)=2
A =

-2 3 1
4 1 1
1 2 3

A(1:2,:)

ans =

-2 3 1
4 1 1

Problem 7
v=[12 25 18 32 18 22 24 15 20 21];
a=max(v)

a =

32

b=min(v)

b =

12

c=sum(v)

c =

207

d=v(3:end)

d =

18 32 18 22 24 15 20 21

e=v(:)

e =

12
25
18
32
18
22
24
15
20
21

Problem 8
A=[3 -6 2;-1 2 5;-2 3 -1];
b=[8;3;-5];
x=A\b

x =

2.0000
0.0000
1.0000
 Using inv()
 Using solve command

Problem 9
A=[-2 3 1;4 1 1;1 -1 3]

A =

-2 3 1
4 1 1
1 -1 3

B=[0 -1 3;2 2 -1;4 3 -2]

B =

0 -1 3
2 2 -1
4 3 -2

A*B

ans =

10 11 -11
6 1 9
10 6 -2

A.*B

ans =

0 -3 3
8 2 -1
4 -3 -6

A^2

ans =

17 -4 4
-3 12 8
-3 -1 9

A.^2

ans =

4 9 1
16 1 1
1 1 9

Problem 10
function [eqn]=kjjj(V)
P=56;%atm
T=450;%K
R=0.08206;%atm.L/g-mol.K
Tc=405.5;%K
Pc=111.3;%atm
a=(27/64)*(((R^2)*(T^2))/(Pc));
b=(R*Tc)/(8*Pc);
eqn=(P+(a/V^2))*(V-b)-(R*T);
end

V0=1;
fzero(@kjjj,V0)

ans =

0.5368

You might also like