如何求点于点之间的距离。

조회 수: 8 (최근 30일)
verire
verire 2022년 11월 22일
답변: jixofoc 2022년 11월 22일
在一个平面内随机分布两组点,如何计算这两组点中每个点之间的距离?这个程序出了错,不知道该如何更改:
Xs=rand(25,1);
Ys=rand(25,1);
Xt=rand(5,1);
Yt=rand(5,1);
d_k=sqrt((Xs-Xt)^2+(Ys-Yt)^2);

채택된 답변

jixofoc
jixofoc 2022년 11월 22일
帮你写了一个,供参考
%% 清空环境变量
close all; clear; clc;
%% 主程序
Xs=rand(25,1);
Ys=rand(25,1);
Xt=rand(5,1);
Yt=rand(5,1);
A = [Xs,Ys];
B = [Xt,Yt]';
d_k=dist(A,B)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 循环及条件语句에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!