MATLAB Answers

Change index in partial area relative to total area

2 views (last 30 days)
Kai Franke
Kai Franke on 14 Jun 2019
Hi folks,
I've been stumbling across a problem a lot lately. The problem is that I find for example minimum values in a special area of a measurement.
Let's explain that step by step using an example:
  • I have a measurement where the signals are given as a 5000x1 double
  • within that measurement I detect a region where several conditions are true -> areaDetected is a 3000x1 double where - let's say - values go from 199:3200. So areaDetected contains the indices of the whole measurement with the area i want to analyse.
  • Now I analyse the signals. In that case a vehicle speed. I want to find the maximum vehicle speed within areaDetected -> e.g.:
[maxVehicleSpeed, indxMaxVehicleSpeed] = max(signalVehicleSpeed(areaDetected))
  • indxMaxVehicleSpeed might be 200, but that is the index within areaDetected. So far so good.
  • afterwards i want to find the spot where the speed crosses a certain value:
indxVehicleSpeedCrossing = find(signalVehicleSpeed(areaDetected(indxMaxVehicleSpeed:end)) <= threshold + deviation, 1, 'first')
  • the new area would be 399:3200 (since areaDetected(200) equals 399)
  • indxVehicleSpeedCrossing e.g. 200
  • absolute index should be 598 (from the perspective of the areaDetected)
  • now I want to find the minimum vehicle speed after the crossing
[minVehicleSpeed, indxMinVehicleSpeed] = min(signalVehicleSpeed(areaDetected(indxVehicleSpeedCrossing:end)));
  • so the new area would be 598:3200 (since areaDetected(200) equals 399)
  • now the problem becomes more obvious: let's say the index where my minimum is found is 100 but in perspective on the full areaDetected the minimum should be at 697 right?
Instead of adding the missing range to my index I'm looking for a more elegant way to solve that problem.
Here is a visualisation of the problem:
The black circled values are the indices where there is no correction within the area.
Unbenannt.PNG
I hope the description of the problem is understandable. I have the feeling that the solution is a one-liner or I just need to change the syntax. Anyway the search-function didn't offer any solutions.
Looking forward for help.
Kind regards!

  0 Comments

Sign in to comment.

Answers (0)