MATLAB: Using a for loop to create multiple rotation matrices

for loopmultiple matricesrotation matrix

POV = [5;3;6];
Rtheta = [0.5;0.5]*(pi/180); %Roll angle
Ptheta = [0;0.5]*(pi/180); %Pitch angle
Htheta = [0;0]*(pi/180); %Head angle
I am trying to input the above matrices into a rotation matrix to form different rotation matrices based upon the above attitude angles.
for i = 1:1:length(Htheta);
Rot(i,:) = Rh(Htheta(i,:))*Rp(Ptheta(i,:))*Rr(Rtheta(i,:)); %Rot. matrix using attitude angles
POVrot = Rot(i)*POV;
end
Rh, Rp, and Rr are rotation matrix functions outside of the main script. The above for loop is me trying to create mutliple rotation matrices and apply each individual rotation matrix to a point (POV) based on the respective attitude angles. I have not been able to get it to work. Any guidance would be greatly appreciated.

Best Answer

As cell?
for i = 1:1:length(Htheta);
Rot{i} = Rh(Htheta(i,:))*Rp(Ptheta(i,:))*Rr(Rtheta(i,:)); %Rot. matrix using attitude angles
POVrot{i} = Rot{i}*POV;
end