Filter löschen
Filter löschen

compare Element of 2 arrays different size

1 Ansicht (letzte 30 Tage)
Jay Samin
Jay Samin am 27 Jul. 2016
Beantwortet: Selva Karna am 29 Jul. 2016
Hello everyone,
I have come across a few issues whilst working on my project. I would greatly appreciate any help
In Workspace 3 arrays are given : "Section_v "with 22 Elements, Covered Road 412 Elements and Speedlimits 23 Elements. Each element of Section_V corresponds to a value of Speedlimits
For example: For 12.3496 meter there is a Speedlimit of 20 km/h (see attached)
Now to get into the crux of the issue.
I would like to create an m-file that compares the first element of Section_v with the first element of Covered Road and if it is found to be greater, it will go to next element of Covered Road. This will go on untill this condition does not apply and thus the value off "speedlimits" will be written in all cells by the new Array Speed column where this condition is correct.
At the next Step the first value of "section_v" will add up to the second one and the process will continue
Example:
1) 12,3496 >= 12,3496 --> Speed = 20 (first element off the Speed array)
12,3496 >= 24,85227 this not true, therefore we have to take the value of the next element of Section_V|_|
2) 12,3496 +236,5407 >= 24,85227707 --->> Speed = 50 (second element off the Speed array )
12,3496 +236,5407 >= 38,9555219 --->> Speed = 50 ( third element off the Speed array )
12,3496 +236,5407 >= 300 this not true, therefore we have to take the value of the next element of Section_V
3) 12,3496 +236,5407 +623,4659857 >= 300 -----> Speed = 30 ( fourth element off the Speed array )
..ect
One of the difficulties with this is that " Section_V " vectors are not the same length as those in "Covered Road ". Therefore , I thought that if n = 24 the value of the rest from element of "speed" would be 130.
Once again I would appreciate any help that is available.
Many thanks
JayJay
  3 Kommentare
Jay Samin
Jay Samin am 27 Jul. 2016
Bearbeitet: Jay Samin am 27 Jul. 2016
Heey Stephen,
thank you first for the quick answer,I have uploaded the data. Speedlimit is an element of the struct route. ("route.infos.Speedlimits")
ps: based on lat and lon coordinates of Speed Limits, I was able to calculate the distances between 2 adjacent points and that is even the array "Section_V" . The first element of speedlimits belongs to the first element of sectiom v. This means during this section of the road (section V), should the car drive with the corresponding speed shown in the table
Thank you for your help
JayJay
Jay Samin
Jay Samin am 29 Jul. 2016
Heey Stephen, I solved the problem but thnx any way :)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Selva Karna
Selva Karna am 29 Jul. 2016
use isequal commands

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by