I'm being given the following information:
where "routenummer" stands for roadnumber, "gemeente" for city, "afstand" for distance in km and "moeilijkheidsgraad" for difficulty.
I need to create a matrix titled difficultRoads with all of the given information of the walking roads with a difficulty lower than 3. To make this specific matrix I need to use matrix routes (which I've made in my code and consists of the original matrix without the information about the cities).
n = 0;
nr = [1; 2; 3; 4; 5; 6; 7; 8]
afst = [13; 13; 9.5; 4.5; 11; 12; 16; 8]
gr = [1; 3; 2; 2; 3; 3; 3; 2]
routes = zeros(8, 3);
routes(:,1) = nr;
routes(:,2) = afst;
routes(:,3) = gr;
routes
for r = 1:8
if routes(r,2) > 10
n = n + 1;
end
end
for r = 1:8
sel= (routes(r,3) < 3)
% I have no clue on what to do here, gr(sel)
% doesn't seem to work and I have no idea how
% I could turn it into a matrix aswell with
% only the extra information of the required roads.
end
disp(['The number of roads with a distance bigger than 10 km is ' num2str(n)])
As you can see, I also created the vectors nr, afst, gr and the matrix routes. That is an other part of the assignment and can be ignored.
When runned a matrix should be formed like this
1 Merelbeke 13 1
3 Kluisbergen 9.5 2
4 Kruishoutem 4.5 2
8 Oudenaarde 8 2
Thanks in advance!