Vector in a Matrix 2x2, calculate the length of the vector

2 ビュー (過去 30 日間)
Manuel
Manuel 2022 年 12 月 2 日
移動済み: Voss 2022 年 12 月 3 日
%Hello Matlab friends
%I would like to calculate the length aut of a 2x2 Matrix. A=[0 0;12 12]; two points x0/y0 and x12/y12.
A=[0 0;12 12]
l= sqrt((A(2,1)-A(1,1))^2+(A(2,2)-A(1,2))^2);
%i am happy for every help, thank you
  1 件のコメント
Torsten
Torsten 2022 年 12 月 2 日
編集済み: Torsten 2022 年 12 月 2 日
Your code is correct. Or what was your question ?
An alternative code:
A=[0 0;12 12];
l = norm(A(1,:)-A(2,:))
l = 16.9706

サインインしてコメントする。

回答 (1 件)

Steven Lord
Steven Lord 2022 年 12 月 2 日
If I understand your question correctly I think what you want is the vecnorm function.
  1 件のコメント
Manuel
Manuel 2022 年 12 月 3 日
移動済み: Voss 2022 年 12 月 3 日
%Thanks for you immediate help!
%i have one more question, how can i shorten a Vector how is not in the origin. Again two Points and the first Point should remain on its place.
B=[9 0; 4.5 8 ]; two Points x9/y0 and x4.5/y8. I would like to shorten the vector. But the first Point should stay where it is. i tryied as followed:
v=[B (:,1);B(:,2)*1/3]
or
V=[B (1,1:2);B(2,1:2)*1/3];
or
s=B (:,1); first point
t= B(:,2)*1/3; %second point shortened by 1/3
u= [s; t];
%Thank you in advance!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by