I need to create a function that calculates the euclidean distance between two points A(x1,y1) and B(x2,y2) as d = sqrt((x2-x1)^2+(y2-y1)^2)).
Am lost please help.

댓글 수: 3

Oleg Komarov
Oleg Komarov 2012년 5월 5일
What have you done so far?
http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
suma g
suma g 2018년 2월 8일
Sir im a researcher.Im working on emotion recognition classification through eyes and eyebrows.I have detected/cropped the feature ,now i need to calculate the distance between the nodal points in eye through matlab.I will calculate the distance of eyes for different expressions.Based om that i will determine the expression.Can u help me out.??? My email id sumaavani2@gmail.com
Muhammad Uzair
Muhammad Uzair 2021년 6월 9일
You can use D = pdist(X) to calculate pairwise isdtance in MATLAB, default distance is Euclidean. If you want to compare with other distance metrices like cityblock etc. then use D = pdist(X,distance)

댓글을 달려면 로그인하십시오.

 채택된 답변

Image Analyst
Image Analyst 2012년 5월 5일

1 개 추천

Do you know how to create functions yet? You just do this:
function [output1 output2] = yourFunction(input1, input2, input3) % Then your code (like you gave above).
Change the inputs and outputs to what you need (like my "input1" = your "x1" etc.), save it in an m-file and then you're done. Let me know if you still need my hint to be more explicit, and if this is a homework question.

댓글 수: 3

Grimm
Grimm 2012년 5월 5일
Yes make it more explicit if you can please. I would really like an example that i can look at so I have start from there. To answer your other question it's not really homework, it's an exercise question from my textbook to learn more about functions. The real homework will be much harder.
Image Analyst
Image Analyst 2012년 5월 5일
function euclideanDistance = CalcDistance(x1, y1, x2, y2)
euclideanDistance = sqrt((x2-x1)^2+(y2-y1)^2);
Grimm
Grimm 2012년 5월 5일
Thanks this is really helpful

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2012년 5월 5일

댓글:

2021년 6월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by