Top 10 Most Downloaded Games on Play Store in 2024
Matlab instructions
1. %Coursework of Matlab
clc
clear
%%%% answer to question (a)
data=load('road_data.txt');
%put the first column of data(time in seconds) into variable T
T=data(:,1);
%put the second column of data(Sin km/h)into variable S
S=data(:,2);
%%%%% answer for question (b)
%speed=S*0.277777
speed=(S/3600)*1000;
%this will display my speed in meter per second
figure (1);
plot(T,speed,'ro-','MarkerFaceColor','y')
%label x axis as:Time (seconds)
xlabel('Time(seconds)')
%label y axis as:Speed into meter/seconds
ylabel('speed(meter/seconds)')
%gives a title tothe graph:
title('Graph showing speed vs Time')
%%%%%%%%%%%% answer for questin (c)
%convert the S vector from kmeter per hours to miles per hours
2. S_mph = S /1.609344;
%calculates the mean
Mean_S = mean(S_mph);
%show the mixmum value
Max_S = max(S_mph);
%writes and displayes "Average speed=X Miles/Hour" where X is mean value
%computed by matlab code,
Ave_Speed_disp=['Average speed = ', num2str(Mean_S,'%.2f'), 'miles per hour'];
disp (Ave_Speed_disp)
%stores the string "Maximum speed= X Miles/Hour"
fprintf ('Maximum Speed = %.2f miles/hourn', Max_S)
%%%%%%%%%%%%%%% answer to question (d)
total=length(S);%this command shows how many values are in the S column
zeros=sum(S==0);%this shows how many zeros there are in the S column
p=sum(S==0)/total*100;
% With the information I have this calculation works out how long the
% car has been in a stable position
fprintf('The car was stationary = %f percent of the time',p)
%%%% answer to question (e)
acceleration=diff(S)./diff(T);
acceleration2=[0;acceleration];
plot(T,acceleration2,'-mo','markerfacecolor','g') % plot the grips in the
3. xlabel('T(sec)') %labels the X axis of the graph
ylabel('acceleration(m/sec^2)') % labels the Y axis of the graph
title('Acceleration Vs Time') % Title of the graph
%%%%%% answer for question (f)
distance = cumtrapz(T,S);
grid on
dist2 = 0;
fori=1:length(S)-1
dist2(i+1)=dist2(i)+(S(i)+S(i+1))*(T(i+1)-T(i))/2;
end;
plot(T,distance);
title('Distance Vs Time')
xlabel('Time/Seconds')
ylabel('Km')
%%%% answer question (g)
Y = sum(S>65);
fprintf('n The speed limit was exceeded %ftime',Y);