Filter löschen
Filter löschen

about angles between each column

1 Ansicht (letzte 30 Tage)
Bo Wang
Bo Wang am 11 Mär. 2016
Kommentiert: Roger Stafford am 11 Mär. 2016
Hi, I have a problem that let me determine the angles between each columns in a m*n matrix. I already know that how to calculate the angle between each column, but how can I store these values in a n*n matrix G where Gij is the angle between ith column and jth column? Here is my code:
function G=angle(a)
[m,n]=size(a);
G1=atand(norm(cross(a(:,1),a(:,1)),dot(a(:,1),a(:,1))));
end
Thank you!

Antworten (1)

Stalin Samuel
Stalin Samuel am 11 Mär. 2016
I am not sure about the formula. But you can refer the below code for store the values
[m,n]=size(a);
for it1 = 1:n
for it2 = 1:n
G1(it1,it2)=atand(norm(cross(a(:,it1),a(:,it2)),dot(a(:,it1),a(:,it2))));
end
end
  2 Kommentare
Bo Wang
Bo Wang am 11 Mär. 2016
Thank you! It works perfect!
Roger Stafford
Roger Stafford am 11 Mär. 2016
That should be 'atan2d' in your code, not 'atand'. The function 'atand' takes only one argument.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by