A-star obstacles
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Geoff
am 22 Mär. 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 Kommentare
Geoff
am 22 Mär. 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.
Siehe auch
Kategorien
Mehr zu Language Fundamentals finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!