% CMM Assignment Question 2: ' ' 'Linewidth' 'Thinking' 'Speed'

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

% Cmm Assignment Question 2

s= [ 30 45 60 75 90 120]';

th = [ 5.6 8.5 11.1 14.5 16.7 22.4 ]';

br = [5.0 12.3 21.0 32.9 47.6 84.7 ]';

%Given T= a0 exp(b1*s);
% expressing as y=mx+c
% log th = log a0 + b1 * sp;

logth = log(th);
z=[ones(size(s)) s];
coeffth = (z' * z) \ z' * logth;

a0 = exp(coeffth(1));
b1 = coeffth(2);

T = a0 * exp(b1*s);

%Given B= a1 exp(b2*s);
% expressing as y=mx+c
% log br = log a1 + b2 * sp;

logbr = log(br);
coeffbr = (z' * z) \ z' * logbr;

a1 = exp(coeffbr(1));
b2 = coeffbr(2);

B = a1 * exp(b2*s);

%Distance D = T + B

D = T+B;

ss = min(s):0.1:max(s);
T1 = a0 * exp(b1*ss);
B1 = a1 * exp(b2*ss);
D1 = T1 + B1;

subplot(2,1,1);
plot (s,th,'*',ss,T1,'Linewidth',3);
xlabel('Thinking');
ylabel('Speed');
subplot(2,1,2);
plot (s,br,'*',ss,B1,'Linewidth',3);
xlabel('Braking');
ylabel('Speed');

% Distance Value at speed 80 km/h


ans=a0 * exp(b1*80) + a1 * exp(b2*80);

fprintf(' The total Distance stopping Function : D = %f * exp(%f * s) + %f * exp(%f *


s) \n \n ' , a0 ,b1 ,a1,b2);
fprintf('The total stopping distance of the vehicle at speed of 80 Km/hr : %f
metres',ans);

You might also like