For loop completing the wrong steps.
Mostrar comentarios más antiguos
The aim of the code is to find the position where a event occurs (Position) and then extract the height levels (Level_Either_Side) 5 itervals before and 5 itervals after, a certain height value.
The Position code works find but the Level_Either_Side code is where the error occurs.
This is the code:
for z = 1:length(Componentry_New);
Position(z) = find(Componentry_Table == Componentry_New(z,1));
end
Level_Either_Side = [];
for p = 1:length(Componentry_New);
Level_Either_Side = [Level_Either_Side ; Sorted_Level(Position(1,p),1)-5:1:Sorted_Level(Position(1,p),1)+5];
end
The output I get is this:
46.87983 47.87983 48.87983 49.87983 50.87983 51.87983 52.87983 53.87983 54.87983 55.87983 56.87983
Which is finding the level and then subtracting or adding 1, 2, 3, 4, 5, to thefound value 51.87983., instead of extract the 5 values before and after.
Does anybody know what mistake I have made
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!