Professional Documents
Culture Documents
Script file
Q3
% x=-4:0.5:4;
% y=((x.^2)./(2+sin(x)+(x.^4)));
% plot(x,y);
% title('plot of y=((x.^2)./(2+sin(x)+(x.^4)))');
% xlabel('x');
% ylabel('y');
% grid on
Q5
Script file
% x=-4:0.2:3;
% y=-3.*x.^4+10.*x.^2-3;
% figure(1)
% plot(x,y,'r*-');
% xlabel('x');
% ylabel('-3.*x.^4+10.*x.^2-3');
% figure(2)
% x=-4:0.2:4;
% y=-3.*x.^4+10.*x.^2-3;
% plot(x,y,'g');
% xlabel('x');
% ylabel('-3.*x.^4+10.*x.^2-3');
Q8
% r=7.5;
% Centre=(4.2,2.7);
% a=4.2;
% b=2.7;
% t=(0:pi/100:2*pi);
% As
% (x-a)=r*cos(t);
% (y-b)=r*sin(t);
% x=r*cos(t)+a;
% y=r*sin(t)+b;
% plot(x,y,'g.--');
Q7
Scrip file
% x=0:pi/100:2*pi;
% y=sin(x).^2.*cos(2*x);
% y1=2.*sin(x).*cos(x).*cos(2*x)-2.*sin(x).^2.*sin(2*x);
% plot(x,y,x,y1,'c+-.');
% legend('y','y1');
Q9
Script file
% t=linspace(-pi,pi,100);
% x=sin(t).*cos(t); y=1.5*cos(t);
% plot(x,y,'k')
% axis([-2 2 -2 2])
% title('Parametric equation: x=sin(t)cos(t) y=1.5cos(t) for -\pi to \pi')
% xlabel('x-->')
% ylabel('y-->')
Chapter 6
Q1
Script file
disp('Part (a)')
12-4<5*3
disp('Part (b)')
y=8/4>6*3-4^2>-3
disp('Part (c)')
y=-3<(8-12)+2*(5>18/6-4)^2
disp('Part (d)')
(~5+~0)*6==3+3*~0
>> Irfan
Part (a)
ans =
logical
Part (b)
y=
logical
Part (c)
y=
logical
Part (d)
ans =
logical
1
Q2:
Script file:
y=
logical
Part (b)
y=
logical
Part (c)
y=
logical
Q3
Script file
Part (a)
ans =
1 1 0 1 1 1 1 1
Part (b)
ans =
0 0 0 0 0 0 0 1
Part (c)
ans =
0 0 0 1 0 1 0 0
Part (d)
ans =
0 1 1 0 1 0 0 0
Q4
Script file
w=
0 -1 0 3 -3 0 1 0
or
w=
-1 0 3 -3 1
Q5
Script file
disp('Part (a)')
-3&3
disp('Part (b)')
~5<4&~0>-3
disp('Part (c)')
-2&2>3|8/3
disp('Part (d)')
-3<-1<~0|5<4<3;
Part (a)
ans =
logical
Part (b)
ans =
logical
Part (c)
ans =
logical
Part (d)
ans =
logical
1
Chapter 7
Q1
Script file:
disp('Part (a)')
x=[-1.5 5];
y=malik(x);
disp('The test values for y(x) are:')
disp(y)
%
%part b
x=-2:.1:6;
plot(x, malik (x));
title('y(x)=(-0.2x^3 + 7x^2)e^{-0.3x}')
xlabel('x-->')
ylabel('y-->')
Function file :
y=(-0.2*x.^3+7*x.^2).*exp(-0.3*x);
Command Window:
Part (a)
The test values
for y(x) are:
25.7595
33.4695
Q2
Script file:
disp('Part (a)')
th=[pi/6, 5*pi/6];
r=polarmalik(th);
disp('The test values for r(theta) are:')
disp(r)
%
%part b
th=linspace(0,2*pi,200);
polar(th,polarmalik(th));
title('r(\theta)=4cos(4sin(\theta))')
Function file:
function r = polarmalik(theta)
%angles in radians
r=4*cos(4*sin(theta));
Command Window:
Part (a)
The test values for r(theta) are:
-1.6646 -1.6646 1
Q3
Script file:
disp('Part (a)')
gmi=5;
Lkm = LkmToGalm(gmi);
disp('The fuel consumption of a Boeing 747 in liters/km is:')
disp(Lkm)
disp('Part (b)')
gmi=5.8;
Lkm = LkmToGalm(gmi);
disp('The fuel consumption of a Concorde in liters/km is:')
disp(Lkm)
Function file:
function Lkm = LkmToGalm(gmi)
Lkm = gmi*4.40488/1.609347;
Command Window:
Part (a)
The fuel consumption of a Boeing 747 in liters/km is:
13.6853
Part (b)
The fuel consumption of a Concorde in liters/km is:
15.8750
Q4
Script file:
disp('Part (a)')
den=7860;
sw = DenTOSw(den);
disp('The specific weight of steel in lb/in^3 is:')
disp(sw)
disp('Part (b)')
den=4730;
sw = DenTOSw(den);
disp('The specific weight of titanium in lb/in^3 is:')
disp(sw)
Function file:
function sw = DenTOSw(den)
sw=den/2.76799e4;
Command Window:
Part (a)
The specific weight of steel in lb/in^3 is:
0.2840
Part (b)
The specific weight of titanium in lb/in^3 is:
0.1709
Q5
Script file;
kts=400;
fps = ktsTOfps(kts);
fprintf('A speed of 400 kts is %.1f ft/s\n',fps)
Function file:
function fps = ktsTOfps(kts)
fps=kts*6076.1/3600;
Command Window:
A speed of 400 kts is 675.1 ft/s
Chapter 9
Q1
F=@ (x) exp(0.3*x)-x^2+4;
fplot(F,[0 5])
xlabel('x')
ylabel('y')
r=fzero(F,3)
Command Window:
r=
2.4693
Q2
F=@ (x) 2*cos(x)-0.5*sqrt(x)-1;
fplot(F,[0 5])
xlabel('x')
ylabel('y')
r=fzero(F,3)
Command Window:
r=
0.7683
Q3
F=@ (x) x^3-5*x^2.5+exp(0.9*x)+4*(x+1)+2;
fplot(F,[0.5 6])
xlabel('x')
ylabel('f(x)')
x1=fzero(F,2)
x2=fzero(F,5)
Command Window:
x1 =
1.9830
x2 =
5.7555
Q4
F=@ (x) x^2-5*x*sin(3*x)+3;
fplot(F,[0 6])
xlabel('x')
ylabel('y')
r1=fzero(F,2)
r2=fzero(F,3)
Command Window:
r1 =
2.3656
r2 =
2.8435
Q5
mu=0.55;
g=9.81;
m=25;
Fun=@ (x) mu*m*g./(cosd(x)+mu*sind(x));
x=1:90;
F=Fun(x);
plot(x,F)
xlabel('Theta (deg)')
ylabel('F (N)')
Fs=150;
Funs=@ (x) mu*m*g./(cosd(x)+mu*sind(x))-Fs;
ths=fzero(Funs,70)
Command Window:
ths =
66.8176