You are on page 1of 9

Question.No.

1
% Question 1
clear all
clc
x1=[-4:0.05:1.7];
x2=[2.3:0.05:8];
y1=(x1.^2-4*x1-5)./(x1-2);
y2=(x2.^2-4*x2-5)./(x2-2);
plot(x1,y1,x2,y2)
title('Question No.1')
xlabel('x')
ylabel('y'
Question No.1
30

20

10

-10

-20

-30
-4

-2

Question.No.2
% Question.No.2
clear all
clc
t=0:0.2:30;
x_t=-0.28*(t.^2)+6.5*t+61;
y_t=0.18*(t.^2)-8.5*t+65;
r=x_t+i*y_t;

2
x

r=sqrt((x_t.^2+y_t.^2));
theta=(180/pi)*atan(y_t./x_t);
plot(x_t,y_t)
xlabel('x(t)')
ylabel('y(t)')
title('Trajectory of squirrel (Question 2a)')
figure
plot(t,r)
xlabel('t')
ylabel('Length')
title('Length of position vector of squirrel (Question 2b)')
figure
plot(t,theta)
xlabel('t')
ylabel('Theta')
title('Angle of position vector of squirrel (Question 2c)')
t=1;

Trajectory of squirrel (Question 2a)


80

60

y(t)

40

20

-20

-40

10

20

30

40

50
x(t)

60

70

80

90

100

Length of position vector of squirrel (Question 2b)


100
90
80

Length

70
60
50
40
30
20

10

15
t

20

25

30

Angle of position vector of squirrel (Question 2c)


50

Theta

-50

-100

10

15
t

20

25

30

Question.No.3
% Question.No.3
clear all
clc
c=0.05;
tau_1=0.05;
tau_2=500;
G_inf=5000;
omega_nat=-4:0.2:3; % As omega was fom 0.0001 to 1000
omega=10.^omega_nat;
term1=((1+(omega*tau_2).^2)./(1+(omega*tau_1).^2));
Gp=G_inf*(1+c*log(term1)/2);
Gpp=c*G_inf*(atan(omega*tau_2)-atan(omega*tau_1));
subplot(2,1,1)
semilogx(omega,Gp)
xlabel('freuency (omega)')
ylabel('G_{prime}')
subplot(2,1,2)
semilogx(omega,Gpp)
xlabel('freuency (omega)')
ylabel('G

prime

8000
7000

6000

5000
-4
10

-2

10

10
freuency (omega)

10

10

double prime

400
300
200
100
0
-4
10

-2

10

10
freuency (omega)

10

10

Question.No.4
% question 4
clear all
clc
L=20;
E=200e9;
I=348e-6;
w=5e3;
x1=[0:0.1:(2*L/3)];
term1_y1=(-w*x1)/(24*L*E*I);
term2_y1=((L*x1.^3)-((16*L.^2*x1.^2)/9)+((64*L.^4)/81));
y1=term1_y1.*term2_y1;
x2=[(2*L/3):0.1:L];
term1_y2=(-w*L)/(54*E*I);
term2_y2=((2*x2.^3)-(6*L*x2.^2)+((40*L.^2*x2)/9)-((4*L.^3)/9));
y2=term1_y2.*term2_y2;
plot(x1,y1,x2,y2)
title('Deflection of beam , Note that at x=13, a discontinuty occurs')
xlabel('x')
ylabel('y')

Deflection of beam , Note that at x=13, a discontinuty occurs


0

-0.02

-0.04

-0.06

-0.08

-0.1

-0.12

10
x

12

14

16

18

20

Question.No.5 (a-c)
% Question .No.5a
clear all
clc
G=[68,83,61,70,75,82,57,5,76,85,62,71,96,78,76,68,72,75,83,93];
sorted_G=sort(G);
bar(G)
title('Bar graph of unsorted G')
axis([0 21 0 100])
ylabel('Scores')
figure
bar(sorted_G)
title('Bar graph of sorted G')
axis([0 21 0 100])
ylabel('Scores')
% End of part a of question 5
% Start of part b of question 5
figure
hist(G)
title('Histogram of grades ')
% End of part b
% Start of part c of question 5
figure
grd=[2 4 8 4 2];
pie(grd)
title('Class Grades')
legend('A','B','C','D','E');
% End of part c of question 5

Bar graph of unsorted G


100
90
80
70

Scores

60
50
40
30
20
10
0

10

12

14

16

18

20

14

16

18

20

Bar graph of sorted G


100
90
80
70

Scores

60
50
40
30
20
10
0

10

12

Histogram of grades
7

0
0

10

20

30

40

50

60

70

80

90

100

Class Grades
10%

A
B
C
D
E

10%

20%

20%

40%

Question.No.5(d)
% question 5d
clear all
clc
data_2004=[2345,4363,3212,4565,8776,7679,6532,2376,2238,4509,5643,1137];
data_2005=[2343,5766,4534,4719,3422,2200,3454,7865,6543,4508,2312,4566];
x=[1 2 3 4 5 6 7 8 9 10 11 12]
months={'Jan' 'Feb' 'Mar' 'Aprl' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov'
'Dec'};
width1 = 0.5;
bar(x,data_2004,width1,'FaceColor',[0.2,0.2,0.5],....
'EdgeColor','none')
hold on
width2 = width1/2;
bar(x,data_2005,width2,'FaceColor',[0,0.7,0.7],...
'EdgeColor',[0,0.7,0.7]);
hold off
legend('Data for year 2004','Data for year 2005') % add legend
title('Bar graph for data')
xlabel('Month')
ylabel('Inventory')
set(gca, 'XTickLabel', months);
Bar graph for data
9000
8000

Data for year 2004


Data for year 2005

7000

Inventory

6000
5000
4000
3000
2000
1000
0

Jan Feb Mar Aprl May Jun Jul Aug Sep Oct Nov Dec
Month

You might also like