フィルターのクリア

compare Element of 2 arrays different size

1 回表示 (過去 30 日間)
Jay Samin
Jay Samin 2016 年 7 月 27 日
回答済み: Selva Karna 2016 年 7 月 29 日
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 Center および File ExchangeData Type Conversion についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by