compare Element of 2 arrays different size

2 次查看(过去 30 天)
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 个评论
Jay Samin
Jay Samin 2016-7-27
编辑:Jay Samin 2016-7-27
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 2016-7-29
Heey Stephen, I solved the problem but thnx any way :)

请先登录,再进行评论。

采纳的回答

Selva Karna
Selva Karna 2016-7-29
use isequal commands

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by