0% found this document useful (0 votes)
1 views8 pages

MATLAB PROJECT

project of matlab by using linear eqution method by Faisal Umar (23-IE-17) from UET Taxila.

Uploaded by

faisalumar475
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views8 pages

MATLAB PROJECT

project of matlab by using linear eqution method by Faisal Umar (23-IE-17) from UET Taxila.

Uploaded by

faisalumar475
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Modeling and Analysis of Traffic Flow

Objective;
To use linear algebra methods in MATLAB for solving systems of linear equations that
model traffic route for finding the quickest traffic route.

Problem Statement;
Find the quickest route to UET Taxila from Taxila bypass by analyzing traffic flow for
avoiding traffic congestion.

Data Collection

Real-Life Data Description:


The road network from Taxila Bypass to UET Taxila consists of multiple intersections and
routes. The intersections and connecting roads are described as follows:

Intersections:

A: Residential area.

B: Commercial district.

C: School zone.

D: Highway entrance

Routes and Observed Traffic Flow (in vehicles/hour):

A to B: 200

A to C: 150

B to C: 50

B to D: 250

Measuring Setup:
1. Traffic Counters: Manual counting stations were set up at each intersection to record
vehicle flows.
2. Time Period: Measurements were taken during peak hours (8:00 AM – 10:00 AM).

3. Measurement Points: Entry and exit points at intersections.


Table of Measurements:

From To Traffic Flow (vehicles/hour)


A B 200
A C 150
B C 50
B D 250
Apparatus;

o Laptop
o MATLAB Software

General Procedure;
Steps to Solve Linear Equations in MATLAB:
1. Write the System in Matrix Form;
Represent the equations as Ax=b where A is the coefficient matrix, x is the variable vector and b
is the constant vector.
2. Define Matrices in MATLAB;
Create the coefficient matrix A and constant vector b in MATLAB.

3. Choose a Solution Method;


o Use the backslash operator (\\): x = A \ b.
o Use reduced row echelon form (rref): Create the augmented matrix [A∣b] and apply
rref().

Procedure:
1. Setup MATLAB in your pc or laptop. Open MATLAB by clicking on MATLAB Icon.
For Consideration:

2. Define variables for traffic flows on the roads, Let x1, x2, x3, x4 represent the flow rates
on the four routes.

3. Write linear equations based on the traffic flow.

x1+x2=200

x3+x4=150+x1

x3=50+x2

x4=250
4. Write matrix in command window:

A=[1 1 0 0 200;-1 0 1 1 150;0 -1 1 0 50;0 0 0 1 250]

It will show matrix as

1 1 0 0 200
−1 0 1 1 150
0 −1 1 0 50
0 0 0 1 250

5. Then apply command:

B=rref(A)

The row reduce echelon form will appear as:

1 0 0 0 175
0 1 0 0 25
0 0 1 0 75
0 0 0 1 250

6. Apply command;

C=B(:,5);

disp(C)

The C will appear as:

175
25
75
250

For second method :

1. Define matrix A

A=[1 1 0 0 ;-1 0 1 1 ;0 -1 1 0 ;0 0 0 1 ]

1 1 0 0
−1 0 1 1
0 −1 1 0
0 0 0 1
2. Write matrix B as:

B=[200;150;50;250]

It will appear as:

200
150
50
250

3. Apply command;

X=A\B

X will appear as:

175
25
75
250

Results:
The solution from MATLAB yields the traffic flow rates on all routes:

x1=175

x2=25

x3=75

x4=250
MATLAB CODE:

% Define the intersections and traffic flow


intersections = {'A to B', 'A to C', 'B to C', 'B to D'};
traffic_flow = [175, 25, 75, 250]; % Traffic flow in vehicles per hour
% Find the quickest route (maximum flow)
[max_flow, idx] = max(traffic_flow);
% Create a bar chart figure;
bar_colors = repmat([0.2, 0.6, 0.8], numel(traffic_flow), 1); % Default bar color
bar_colors(idx, :) = [1, 0.4, 0.4]; % Highlight quickest route in red
b = bar(traffic_flow, 'FaceColor', 'flat'); % Use 'flat' to allow individual bar colors
b.CData = bar_colors;
% Set the x-axis labels
set(gca, 'XTickLabel', intersections, 'XTick', 1:numel(intersections));
itle('Traffic Flow Between Intersections');
xlabel('Routes');
ylabel('Traffic Flow (Vehicles/Hour)');
grid on;
% Display traffic flow values on top of each bar
for i = 1:length(traffic_flow)
text(i, traffic_flow(i) + 10, num2str(traffic_flow(i)), ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom');
End
% Add a note for the quickest route
text(idx, traffic_flow(idx) + 40, 'Quickest Route', ...
'HorizontalAlignment', 'center', 'VerticalAlignment', 'bottom', ...
'Color', 'red', 'FontWeight', 'bold');
Graphical Representation;

“The Graph Shows That B to D route is quickest route among the all route”
Definition of "Quickest" in the Context;

1) Traffic Flow Assumption:

In traffic analysis, a higher “traffic flow” (more vehicles per hour) often indicates that the route
is more frequently used and might have better conditions (wider roads, faster speeds, etc.).

For this project, "quickest" is interpreted as the route with the highest flow of vehicles.

2) Real-World Implications:

a) B to D has a traffic flow of 250 vehicles/hour, which is the “highest among all routes”. This
suggests it is a popular, well-utilized route, possibly due to factors like:

• Wider roads or faster traffic.


• Direct connection to a major destination.
• Don’t have any delays due to traffic lights, stop signs, or bottlenecks.

Conclusion:
By applying linear algebra and computational tools, this project demonstrates an effective
method to analyze and optimize traffic flow.

You might also like