A-star obstacles
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I'm trying to my a-star program working. I need to plot the path between 2 points while avoiding obstacles. I have already got the path part done, but I'm having some issues with the obstacles.
The user is selecting point one and two, as well as obstacles on a GUI grid.
So far I have c(c==o] = []; to remove the obstacles(o) from the the parent/child numbers(c)
this works with one obstacle as the o value is just one number so it simply deletes it, but for multiple obstacles, o has many numbers inside of it(array) so it just errors and says
" Error using == Matrix dimensions must agree."
I'm guessing this is because, the code above is trying to remove numbers which are in o from c, but they aren't even in c yet, so it can't do it.
How can I resolve this problem?
0 comentarios
Respuestas (1)
Geoff
el 22 de Mzo. de 2012
The problem is you can only compare matrices with the same dimensions, or a matrix with a scalar. You want to compare a matrix with multiple scalars.
You could just loop through each obstacle:
for ob = o
c(c==ob) = [];
end
Edit: this does the same thing (didn't know about this function before). It ought to be more efficient.
c(ismember(c,o)) = [];
2 comentarios
Geoff
el 22 de Mzo. de 2012
Well I can't vouch for the correctness of the rest of your algorithm, but I think I answered your question on how to fix the error message and remove multiple obstacles from your candidates.
Ver también
Categorías
Más información sobre Language Fundamentals en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!