필터 지우기
필터 지우기

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 CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by