필터 지우기
필터 지우기

making a rotation matrix

조회 수: 1 (최근 30일)
Jeroen
Jeroen 2012년 5월 22일
{
clc
b = [cos((angle/180)*pi) -sin((angle/180)*pi);sin((angle/180)*pi) cos((angle/180)*pi)];
for i = 1:1:size(nr_out,1)
a = [nr_out(i,1);nr_out(i,2)];
c = b*a;
rotatie(i) = [c(1,1) c(2,1)];
end
}
Hello I am trying to make a rotation matrix. To do that i multiply the x and y from a file with the rotation matrix [cos(a) -sin(a); sin(a) cos(a)] What I want is that the matrix 'rotatie' grows with in the first column the x value ( c(1,1)) and in the second column the y-value(c(2,1)).
The error it gives is this: In an assignment A(I) = B, the number of elements in B and I must be the same.
Gr jeroen

답변 (1개)

Honglei Chen
Honglei Chen 2012년 5월 22일
You need to do something like
rotatie(i,:) = [c(1,1) c(2,1)];
But if I understand your question correctly, you can do it without a loop
rotatie = (b*nr_out.').'
  댓글 수: 2
Jeroen
Jeroen 2012년 5월 22일
I am sorry I forgot to tell that the matrix nr_out is a matrix that consist of x,y,z,ex,ey,ez and I have to rotate the whole matrix with 20.58 degree in the xy-plane with their energies.
Honglei Chen
Honglei Chen 2012년 5월 22일
Then you can just use the first solution, use rotatie(i,:) instead of rotatie(i)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by