Professional Documents
Culture Documents
6.8 PROBLEMS:
TCH=[75 79 86 86 79 81 73 89 91 86 81 82 86 88 89 90 82
84 81 79 73 69 73 79 82 72 66 71 69 66 66];
TSF=[69 68 70 73 72 71 69 76 85 87 74 84 76 68 79 75 68
68 73 72 79 68 68 69 71 70 89 95 90 66 69];
%a;
fprintf('average temp for the month in Chicago is;
%g\naverage temp for the month in San fransisco is;
%g\n',mean(TCH),mean(TSF))
%b;
fprintf('%g days temperature is above the average in
Chicago.\n',sum(TCH>mean(TCH)))
fprintf('%g days temperature is above the average in
San fransisco.\n',sum(TSF>mean(TSF)))
%c;
Page 2 of 30
Page 3 of 30
for a=1:1:4
for b=1:1:3
c(a,b)=(a+b)/b^2;
end
end
disp(c)
for i=1:1:4
for j=1:1:4
p(i,j)=factorial(i+j-2)/(factorial(i1)*factorial(j-1));
end
end
disp(p)
for i=1:1:7
for j=1:1:7
Page 4 of 30
p(i,j)=factorial(i+j-2)/(factorial(i1)*factorial(j-1));
end
end
disp(p)
else if i==2
d(j+n)=d(j+n-1)+d(j+n-2);
c(i,j)=d(j+n);
else if i==3
d(j+2*n)=d(j+(2*n-1))+d(j+(2*n-2));
c(i,j)=d(j+2*n);
else if i==4
d(j+3*n)=d(j+(3*n-1))+d(j+(3*n-2));
c(i,j)=d(j+3*n);
else if i==5
d(j+4*n)=d(j+(4*n-1))+d(j+(4*n-2));
c(i,j)=d(j+4*n);
else if i==6
d(j+5*n)=d(j+(5*n-1))+d(j+(5*n-2));
c(i,j)=d(j+5*n);
end
end
end
end
end
end
end
end
Page 6 of 30
disp(c)
disp(det(c))
Page 7 of 30
else
fprintf('the
end
end
n=1;
while true
if (rem(n,11)==0 & sqrt(n)>132)
fprintf('The required number is: %i\n',n);
break
else
n=n+1;
end
end
format long
Page 8 of 30
format long
c=1;
m=input('please enter avalue: ');
for n=1:m
c=c*(2*n)^2/((2*n)^2-1);
end
disp(2*c)
Page 9 of 30
format short
x=[-3.5 -5 6.2 11 0 8.1 -9 0 3 -1 3 2.5];
for n=1:length(x)
if x(n)>=0
P(n)=x(n);
else
N(n)=x(n);
end
end
P
N
Page 10 of 30
end
end
end
disp(x)
Page 11 of 30
format long
x=input('please enter the value of angle in degrees:
');
y=pi/180*x;
E=1; n=0; S=0;
while E>0.000001
S(n+2)=((-1)^n/factorial(2*n+1)*y^(2*n+1));
E=abs((S(n+2)-S(n+1))/S(n+1))
n=n+1;
end
fprintf('sine(%g) = %g\n',x,sum(S))
Page 12 of 30
else
THR6=(206-0.88*age-RHR)*0.8+RHR
end
INTEN=1;
End
if BMI<18.5
fprintf('Your BMI value is %g,which classifies you
as Underweight. \n',BMI)
else if BMI>=18.5 & BMI<=24.9
fprintf('Your BMI value is %g,which classifies
you as Normal. \n',BMI)
else if BMI>=25 & BMI<=29.9
fprintf('Your BMI value is %g,which
classifies you as Overweight.\n',BMI)
else
fprintf('Your BMI value is %g,which
classifies you as Obese',BMI)
end
end
end
Page 15 of 30
format bank
time=input('please enter the time when the call made in
(day,evening or night) : ','s');
duration=input('please enter the duration of the call :
');
dur=ceil(duration);
switch time
case 'day'
if dur>=1 & dur<10
s=0.1*dur
end
Page 16 of 30
if dur>=10&dur<=30
s=1+(0.08*(dur-10))
end
if dur>30
s=2.60+(0.06*(dur-30))
end
case'evening'
if dur>=1&dur<10
s=0.07*dur
end
if dur>=10&dur<=30
s=0.7+(0.05*(dur-10))
end
if dur>30
s=1.70+(0.04*(dur-30))
end
case'night'
if dur>=1&dur<10
s=0.04*dur
end
if dur>=10&dur<=30
s=0.4+(0.03*(dur-10))
end
Page 17 of 30
if dur>30
s=1+(0.02*(dur-30))
end
end
format bank
p=randi(20);
fprintf('the amount to be paid is..: $%i \n',p),
payment=input('Enter the vale of your payment:$');
if payment<p
disp('error..your payment is not sufficient!!')
else
ch=payment-p;
fprintf('your change is $%i \n',ch)
end
Page 18 of 30
%a;
Dg=150; Vd=50; Ka=1.6; Ke=0.4;
t=0:10;
cp=Dg*Ka./(Vd*(Ka-Ke)).*(exp(-Ke*t)-exp(-Ka*t))
plot(cp,t,'r--*','markeredgecolor','b')
%b;
t=0:4:24
Cp=Dg*Ka./(Vd*(Ka-Ke))*(exp(-Ke*t)-exp(-Ka*t))
figure
plot(Cp,t,'--k')
Page 19 of 30
Page 20 of 30
m=0; l=0;
for i=10:500
k=0;
for j=1:i
if rem(i,j)==0
k=k+1;
n=i;
else continue
end
end
if k<=2
m=m+1;
x(m)=n;
end
end
for c=1:(length(x)-1)
if (x(c+1)-x(c))==2
l=l+1;
z(l)=x(c);
Page 21 of 30
z(l+1)=x(c+1);
l=l+1;
end
end
v=reshape(z,2,22)'
outft3=inp*35.287;
case 'ft3'
outft3=inp;
outm3=inp*0.0283;
outL=outm3/30;
end
switch out
case 'm3'
disp(outm3)
case 'L'
disp(outL)
case 'ft3'
disp(outft3)
end
j=j+1;
x(j)=x(j-1)+s;
end
end
disp(mean(x))
end
plot(x,y)
Page 24 of 30
table=reshape(randperm(12),6,2);
disp('League table')
disp(' ')
disp(table)
Page 25 of 30
Cp=48.5+9.188*10^-2*T-8.54*10^-5*T.^2+32.4*10^9*T.^3;
case 'O2'
Cp=29.1+1.158*10^-2*T-0.6076*10^5*T.^2+1.311*10^-9*T.^3;
case 'N2'
Cp=29+0.2199*10^-2*T-0.5723*10^-5*T.^22.871*10^-9*T.^3;
otherwise
disp ('error')
end
dis(1,:)=T; dis(2,:)=Cp;
disp(gas)
disp('
temp.
Heat_capacity ')
disp(dis')
Page 27 of 30
Page 28 of 30
N=2
end
HCD=(score-CR)./CS*113;
t=[HCD N]
Page 30 of 30