Stopping the automation of a 10 x 1 into a 10x10 matrix in Matlab.

4 ビュー (過去 30 日間)
Shrishti Yadav
Shrishti Yadav 2021 年 11 月 20 日
編集済み: Star Strider 2021 年 11 月 20 日
S1 is a 10 x 1 double. and S is 1 x 2 double. I am doing some calculations with those numbers and in the end for my theta I should just get distinct 10 x 1 double array too. But for some reason I am getting 10 x 10 for theta. I don't understand why or how to fix it.
% Calculating the distance from original source location for all locations with error.
sx = S1(:,1) - S(1);
sy = S1(:,2) - S(2);
l = sqrt((sx).^2+ (sy).^2); %distance between original source location and error source locations.
zz = sqrt((S1(:,1)).^2+ (S1(:,2)).^2); % distance of error source locations from origin.
ss = sqrt((S(1)).^2+ (S(2)).^2); %distance of the source from origin.
% Calculating the resolution for a traingle with lengths l, zz, ss
n = (zz.^2 + ss.^2 - l.^2);
d = (2 .* zz .* ss);
theta = acos(n/d);

採用された回答

Star Strider
Star Strider 2021 年 11 月 20 日
編集済み: Star Strider 2021 年 11 月 20 日
Use element-wise dividion (./) iunstead of (/) in the acos call —
theta = acos(n./d)
EDIT — See Array vs. Matrix Operations for details.
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by