- Joined
- Dec 15, 2011

- Messages
- 1,888 (0.86/day)

- Likes
- 810

- Location
- Brisbane QLD, Australia

System Name | Белая коробка | Alienware 13R3 | Asus T300 Chi | Synology DS416 w/ 4X6TB WD Red | Huawei P10 |
---|---|

Processor | Intel i7-7700k @ 4.8GHz | Intel i7-7700HQ |

Motherboard | Asus ROG Strix Z270G | Dell/Alienware thing |

Cooling | Noctua NH-D15S w/ A15 & F12 | Double fan |

Memory | G.Skill 2X8gb Trident Z RGB DDR4 3000mhz | DDR4 2X8GB 2400mhz |

Video Card(s) | EVGA GTX 1080 Ti SC2 | Nvidia GeForce GTX 1060 6GB |

Storage | Samsung 960 EVO 500GB, Crucial MX200 500GB, 1X WD 4TB Black | 256gb M.2 SSD, 512GB Intel 600p M.2 |

Display(s) | LG 27UD68 & BenQ FP241W (ANCIENT!) | 13" 1080p IPS & Sony X7000E 49" 4K HDR TV |

Case | InWin 301 (white) | Alienware 13R3 |

Audio Device(s) | Creative Sound Blaster Z | onboard sound -Onkyo 808 Receiver |

Power Supply | InWin Classic Series 900W | Dell 180W brick |

Mouse | Logitech G403 Wireless | Logitech G602 |

Keyboard | Logitech G810 | Red Square OLD SCHOOL TKL - Gateron Blue |

Software | Windows 10 Home | Windows 10 Home |

Benchmark Scores | Citroen DS3 THP155 DSport6-spd manual| |

I'm having a problem with my MATLAB code I AM A NOOB TO PLEASE BE KIND D: (see below, I've pasted it). Now in the top code, this is my original one except I get no values for TTC (doesn't even appear in the workspace). So I did a bit of experimenting as I find trial and error usually sorts me out but I don't think it did this time. The bottom code is my experimental code, and I get the right number of values for TTC (1464x1) which is good as my excel file has 1464 values. Everything is fine but the TTC values I just can't get :/ If I could get some assistance that would be very much appreciated.

%assignment Problem 2

clc;

clear;

close;

%TTC means Time-To-Collision (s)

%Vf is the speed of the following vehicle (m/s)

%Vl is the speed of the leading vehicle (m/s)

%Ll is the length of the leading vehicle (m)

%t is the time headway

a=xlsread('data_Problem2_Traffic_raw.xls');

%b=a,1); %car

Vf=a,2); %Vf

Vl=a,3); %Vl

Ll=a,4); %Ll

t=a,5); %t

i=0;

d=(t.*Vf)-Ll; % see method for algebraic conversion from t=(d+Ll)/Vf

for i=1:length(d)

if (Vf-Vl)>0

TTC(i)=(d(i)./(Vf-Vl))

fprintf('TTC is equal to %f\n', TTC)

if TTC(i)<1

disp('The safety level is very dangerous')

elseif TTC(i)>1 && TTC(i)<4

disp('The safety level is dangerous')

elseif TTC(i)>4

disp('The safety level is safe')

end

if (TTC(i)<1)<0.03 && (TTC(i)>4)>0.8

disp('The road section is safe')

else

disp('The road section is not safe')

end

elseif (Vf-Vl)<=0

%break

TTC(i)=inf;

end

end

fprintf('displaying TTC equals %f\n', TTC)

-------------------------------------

%assignment Problem 2

clc;

clear;

close;

%TTC means Time-To-Collision (s)

%Vf is the speed of the following vehicle (m/s)

%Vl is the speed of the leading vehicle (m/s)

%Ll is the length of the leading vehicle (m)

%t is the time headway

a=xlsread('data_Problem2_Traffic_raw.xls');

%b=a,1); %car

Vf=a,2); %Vf

Vl=a,3); %Vl

Ll=a,4); %Ll

t=a,5); %t

i=0;

TTC=0;

d=(t.*Vf)-Ll; % see method for algebraic conversion from t=(d+Ll)/Vf

TTC=(d./(Vf-Vl))

for i=1:length(d)

if (Vf-Vl)>0

TTC(i)=(d(i)./(Vf-Vl))

fprintf('TTC is equal to %f\n', TTC)

if TTC(i)<1

disp('The safety level is very dangerous')

elseif TTC(i)>1 && TTC(i)<4

disp('The safety level is dangerous')

elseif TTC(i)>4

disp('The safety level is safe')

end

if (TTC(i)<1)<0.03 && (TTC(i)>4)>0.8

disp('The road section is safe')

else

disp('The road section is not safe')

end

elseif (Vf-Vl)<=0

%break

TTC(i)=inf;

end

end

fprintf('displaying TTC equals %f\n', TTC)

-----------------------------------------