필터 지우기
필터 지우기

Euclidean distance between the rows of the matrix and the vector

조회 수: 4 (최근 30일)
Pawel Szczepanowski
Pawel Szczepanowski 2022년 12월 4일
답변: Torsten 2022년 12월 4일
Hello everyone,
I have a probelm with euclidean distance. I have a matrix A[30x4800] and vector B[1x4800]. I have count euclidean distance beetwen all rows of matrix A and vector B. In result i should get vector C[30x1] (i guess). I tried this
C=sqrt(sum((A-B).^2));
but i gave me C[1x4800]
Do you have any idea what is wrong?
Thank you in advance!

답변 (1개)

Torsten
Torsten 2022년 12월 4일
A = rand(30,4800);
B = rand(1,4800);
C = sqrt(sum((A-B).^2,2))
C = 30×1
28.1049 27.8071 28.3322 28.2607 27.8278 28.2147 27.8511 28.6546 28.4308 28.3258

카테고리

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