How to find Distance Between two points ?

조회 수: 5 (최근 30일)
ankita soni
ankita soni 2019년 12월 30일
댓글: Bhaskar R 2020년 1월 3일
Hello sir/ma'a,m
I want to find out the distance between each points in a time series in matlab. i dont know how to do it
Suppose a time series is [ 0.1, 0.1, 0.2, 0.5, 0.22], i want to find out the distance between each points. be more specific, if we take first column of this matrix(0.1), then i want to find distance between 0.1 and 0.1, 0.1 and 0.2, 0.1 and 0.5, 0.1 and 0.22.
then i want to take second column 0.1 and its distance with each column axcept first one (o.1).
then i want to take third column 0.2 and its distance with each column axcept first and second one (0.1, 0.1)
then want to take forth column 0.5 and its distance with left column axcept first, second and third one (0.1, 0.1, 0.2).
please help me with this.

답변 (1개)

Bhaskar R
Bhaskar R 2019년 12월 30일
a = [ 0.1, 0.1, 0.2, 0.5, 0.22]; % your vector
dist = cell(1, length(a)-1); % your distance cell matrix empty initialization
for ii =1:length(dist)
dist{ii} = a(ii)-a(ii:end); % distances from each point
end
  댓글 수: 3
ankita soni
ankita soni 2020년 1월 3일
but it is not working..
Bhaskar R
Bhaskar R 2020년 1월 3일
I am working on the MATLAB version 2019a, its working fine for me
Can you provide the produced error/not working thing ?

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by