Professional Documents
Culture Documents
Me21b172 Anuj Jagannath Said
Me21b172 Anuj Jagannath Said
Complex matrix
a=zeros(3,3);
for i=(1:3)
for j=(1:3)
a(i,j)=complex((i-1)*3+j,10-((i-1)*3+j));
end
end
a(3,3)=complex(0,1)
a = 3×3 complex
1.0000 + 9.0000i 2.0000 + 8.0000i 3.0000 + 7.0000i
4.0000 + 6.0000i 5.0000 + 5.0000i 6.0000 + 4.0000i
7.0000 + 3.0000i 8.0000 + 2.0000i 0.0000 + 1.0000i
for i=(1:3)
for j=(1:3)
a(i,j)=(i-1)*3+j;
end
end
a(3,3)=0
a = 3×3
1 2 3
4 5 6
7 8 0
b1=[a(1,:);a(3,:)]
b1 = 2×3
1 2 3
7 8 0
b2=flip(a,1);
b2(1,:)=b2(1,1);b2(2,:)=b2(2,1);b2(3,:)=b2(3,1)
b2 = 3×3
7 7 7
4 4 4
1 1 1
b3=flip(a,2)
b3 = 3×3
3 2 1
6 5 4
0 8 7
Q4. a) Generate T
b) Plot P vs T
1
a = 6.172;
b = 10.8752;
T = 1 :2 :50;
T
T = 1×25
1 3 5 7 9 11 13 15 17 19 21 23 25
P=10.^(b+.09245*a./T)
P = 1×25
1011 ×
2.7913 1.1625 0.9757 0.9051 0.8682 0.8454 0.8300 0.8189
plot(T,P,'r');
xlabel("Temperature");
ylabel("Vapour Pressure of benzene");
Q5. a) Generate x
b) Sum of squared differences
c) Plot Z and sin(Z)
a = 5;b = 2;y = 8;
X = 0:.1:10
2
X = 1×101
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000
Z= exp((-1)*a*cos(X))+10*(y^.5)*cos(b*X)
Z = 1×101
28.2910 27.7274 26.0590 23.3524 19.7158 15.2945 10.2652 4.8292
c1=plot(X,Z);
n1="Z";
hold on
c2=plot(X,sin(Z));
n2="sin(Z)";
legend([c1,c2],[n1,n2]);
xlim([0.00 10.00]);
ylim([-50 200]);
legend("Position", [0.63123,0.79699,0.19303,0.10808]);
s=sum((Z-sin(Z)).^2)
s = 5.1557e+05
r=gprnd(1,2,-2,10,1)
r = 10×1
3
-1.5452
-1.7920
11.7497
-1.8103
-0.8372
16.5043
3.1814
-0.3429
-1.9112
-1.9272
dist=makedist('GeneralizedPareto','k',1,'sigma',2,'theta',-2);
z=random(dist,[10,1])
z = 10×1
8.6893
-1.9394
-1.9105
0.1205
-1.5009
10.0958
0.7420
-1.8160
-1.4754
-1.9156
x = linspace(0,10,1000);
y1 = gppdf(x,-.25,1,0);
y2 = gppdf(x,0,1,0);
y3 = gppdf(x,1,1,0);
figure;
plot(x,y1,'-', x,y2,'--', x,y3,':')
legend({'K < 0' 'K = 0' 'K > 0'});
4
5