angle between 2 vectors each time
古いコメントを表示
Hello,
I'm working with experimental data, and I want to calculate a angle between 2 lines or vectors for each group of points that changes through time.
My code to do it is:
for j = 1:size (dados,1);
x1 = o_x;
x2 = q_x;
y1 = o_y;
y2 = q_y;
x3 = q_x;
x4 = j_x;
y3 = q_y;
y4 = j_y;
vetor1 =[ x1(j),y1(j)]-[x2(j),y2(j)];
vetor2 = [x3(j),y3(j)]-[x4(j),y4(j)];
angulo(j+1,1) = acos( dot (vetor1(j),vetor2(j))./ norm(vetor1))./norm(vetor2);
end
My data is like it:
time o_x o_y ...
0.01 234 364
0.02 253 456
(...)
0.03 286 654
And the error is
??? Index exceeds matrix dimensions.
Can you help me?
回答 (1 件)
Walter Roberson
2012 年 6 月 26 日
vetor1(j,:) =[ x1(j),y1(j)]-[x2(j),y2(j)]; vetor2(j,:) = [x3(j),y3(j)]-[x4(j),y4(j)];
angulo(j+1,1) = acos( dot (vetor1(j,:),vetor2(j,:))./ norm(vetor1(j,:)))./norm(vetor2(j,:));
カテゴリ
ヘルプ センター および File Exchange で Resizing and Reshaping Matrices についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!