Matlab matrix merging / cell element extraction / modifying an element in the matrix

Event:
matrix merge / cell element extraction / modify the value of a column of the matrix

code block:

r = 600;
n = 17;% 17paragraph
p = [0 -321.79725039 506.40549922];
allgamma = 2.00943006740867;%115.131862089205
pera = allgamma/(n-1);
f = 0.566081293090563;%32.4340689553974
D = [0 0 0 1];

for i = 1:n

    %
    angle(i) = f + pera*(i-1);
    x(i) = p(1);
    y(i) = - r * sin(angle(i));
    z(i) =   r * cos(angle(i));
    pp(i,:) = [x(i),y(i),z(i)];

    %
    Tbc(i) = {
    
    [[roty(pi)*rotz(pi/2)*roty(angle(i)) (pp(i,:))'];D]};
    Tac(i) = {
    
     Tab*Tbc{
    
    i} };
    
    J(i) = {
    
    MODikine(Tac{
    
    i})};
    Jangle(i) = {
    
    rad2deg(MODikine(Tac{
    
    i}))};
    Jangle{
    
    i}(:,2) = (Jangle{
    
    i}(:,2)-90);
    
end

in:

  • Tbc(i) = {[[roty(pi)*rotz(pi/2)*roty(angle(i)) (pp(i,:))'];D]};is a 3X3 rotation matrix and a 3X1 position matrix and a 1X4 [ 0 , 0 , 0 , 1 ] [0,0,0,1][0,0,0,1 ] The matrices are combined to form a 1X1 cell unit.
  • Use { } to convert the matrix into a cell array, J(i) = {MODikine(Tac{i})}; Jangle(i) = {rad2deg(MODikine(Tac{i}))}; Jangle{i}(:,2)which Jangle{i}is to extract J angle JangleEach cell element of Jangle , that is , each pose matrix .
  • Jangle{i}(:,2);It is Jangle{i}the second column extracted, (Jangle{i}(:,2)-90);which is to subtract 90 from its value, Jangle{i}(:,2) = (Jangle{i}(:,2)-90);and replace the second column value in the original matrix with the calculated second column value.

Guess you like

Origin blog.csdn.net/AlbertDS/article/details/110421938
Recommended