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!