Given the following data representing various distances and
Given the following data representing various distances and their corresponding times. For example, 750 km is done in 12.6 hours. Create three vectors and label them distance, time and speed. Calculate the speed for each entry in the table and store them in the array speed. Find the mean of speeds and store the result in a variable called MEAN. Check the result of b) using the Matlab function mean(...) Find the maximum speed using the Matlab function max(...) and store the result in a variable called MAX. Change the 1st, 3rd, and 5th entries of distance to 900, 600 and 400 without creating a new array. Respectively, change the 1st, 3rd, and 5th entries of time to 15, 11, and 8 without creating a new array. Then find the minimum speed using the Matlab function min(...) and store the result in a variable called MIN.
Solution
MATLAB CODE __________________
create variable for both distance and time separately as shown below and save them together and name it as D_T.mat
for distance
for time
load D_T.mat; % load the variable of distance and time .
speed=distance./time; %% calculating speed
MEAN=(sum(speed)/10); %%% finding mean without using matlab fun
MEAN1=mean(speed);
MAX=max(speed);
% d=distance;
% t=time;
for j=1
distance(j,1)=900;
distance(j,3)=600;
distance(j,5)=400;
time(j,1)=15;
time(j,3)=11;
time(j,5)=8;
end
speed=distance./time; %%% new speed
MIN=min(speed);
| 1060 | 850 | 640 | 750 | 450 | 630 | 370 | 410 | 200 | 570 |
