How to create a manhattan function?

6 views (last 30 days)
Hi
I need to use the manhattan function to calculate the distance of the elements of a matrix that is disorganized to an matrix that is organized. I tried to use a command I saw here in the forum, but it did not work.
  mandist (disorganized matrix, organized matrix);
Can someone help me?
  3 Comments
Geoff Hayes
Geoff Hayes on 27 May 2019
Igor - please clarify what you mean by I tried to use a command I saw here in the forum, but it did not work. Which command did you use? Where did you get this command/code from? What error did you observe (if any)? Please be as descriptive as possible.
Igor Castilho Valenciano
Igor Castilho Valenciano on 27 May 2019
Hi Geoff, I tried to use the command mandist (disordered matrix, ordered matrix) , based on the link (https://www.mathworks.com/help/deeplearning/ref/mandist.html?s_tid=srchtitle). However, when executing, it gave this error:
error: 'mandist' undefined near line 21 column 11
error: called from
manhattan at line 21 column 9
test at line 6 column 1
Then I tried to use this command:
dist = sum(abs(State-adj));
Where State is the disordered matrix and adj is the ordered matrix. However, the function is returning a 1: 3 matrix, and I want the distance from each element to the target state.
These matrices represent an 8-piece set and wish to know the distance from the current state (disordered matrix) to the objective state (ordered matrix) using manhattan heuristics.
Could you understand?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!