Create Matrix By Several Matrices These Matrices Have Elements By Equations

1 Ansicht (letzte 30 Tage)
Create Matrix By Several Matrices These Matrices Have Elements By Equations:
Matrix A = zeros (1728,432), Included Matrices (12,3) puted as Diagonal every element an Equation.
A = [Ax1 Bx1 Cx1 0 0 0 ...; Ay1 By1 Cy1 0 0 0 ....; Ax2 Bx2 Cx2 0 0 0 ...; Ay2 By2 Cy2 0 0 0 ...; ........;Ax12 Bx12 Cx12 0 0 0...; Ay12 By12 Cy12 0 0 0 ...; 0 0 0 Ax1 Bx1 Cx1 0 0 0 ...; 0 0 0 Ay1 By1 Cy1 0 0 0 ... ].
In another word Matrix A = [ Matrix (12*3) Zeros zeros zeros
zeros Matrix (12*3) zeros zeros
zeros zeros Matrix (12*3) zeros ..
... ... ... ... ]
Ax1, Bx1, ..... every element equal equation thier values differes as 288 inputs.
If some one can arrange the loops of matrices and the Main matrix A.
Thanks for any Help
Thanks for any thought
Bashar
  5 Kommentare
bashar halleem
bashar halleem am 21 Mai 2020
IWInt=EIP(1,17); %input('Image Width in EIPxel');
FWInt=EIP(1,8);%input('Format Width in mm');
IHInt=EIP(1,18);%input('Image Height in EIPxel');
FHInt=EIP(1,9);%input('Format Height in mm');
PPx= EIP(1,10);%input('Principal Point X (mm)');
ppy= EIP(1,11);%input('Principal Point y (mm)');
EIP(1,12);%input('k1');
EIP(1,13);%input('k2');
EIP(1,14);%input('k3');
EIP(1,15);%input('p1');
EIP(1,16);%input('p2');
EIP(1,1);%input('Center X (project units)Or (Camera Station Xo');
EIP(1,2);%input('Center Y (project units)Or (Camera Station Yo');
EIP(1,3);%input('Center Z (project units)Or (Camera Station Zo');
P3=nan(1440,1);
for i=1:1440
PxP=Pxl(i,1); %input('x of point in EIPxel');
pxmm=((FWInt*PxP)/IWInt)-PPx;
P3(i,1)=pxmm;
end
P4=nan(1440,1);
for i=1:1440
PyP=Pxl(i,2);%input('y of point in EIPxel');for j=1:2:24; for k=2:2:24; for i=1:1440
pymm=ppy-((FHInt*PyP)/IHInt);
P4(i,1)=pymm;
end
r1=nan(1440,1);sx1=nan(1440,1);sy1=nan(1440,1);dx1=nan(1440,1);dy1=nan(1440,1);xmm1=nan(1440,1);ymm1=nan(1440,1);
for i=1:1440
r1(i,1)=(P3(i,1)^2+P4(i,1)^2)^0.5;
sx1(i,1)=P3(i,1)*(EIP(1,12)+EIP(1,13)*r1(i,1)^2+EIP(1,14)*r1(i,1)^4);
sy1(i,1)=P4(i,1)*(EIP(1,12)+EIP(1,13)*r1(1,1)^2+EIP(1,13)*r1(i,1)^4);
dx1(i,1)=EIP(1,15)*(r1(i,1)^2+2*P3(i,1)^2)+2*EIP(1,16)*P3(i,1)*P4(i,1);
dy1(i,1)=EIP(1,16)*(r1(i,1)^2+2*P3(i,1)^2)+2*EIP(1,15)*P3(i,1)*P4(i,1);
xmm1(i,1)=P3(i,1)+sx1(i,1)+dx1(i,1);
ymm1(i,1)=P4(i,1)+sy1(i,1)+dy1(i,1);
%%%%%%%%%%%%%%%%%%%%%%%%%compute rotation matrix%%%%%%%%%%%%%%%%%%%%%%%%%%
w=EIP(i,4);phi=EIP(i,5);ka=EIP(i,6);
m(i,1)=cosd(phi)*cosd(ka);
m(i,2)=sind(w)*sind(phi)*cosd(ka)+cosd(w)*sind(ka);
m(i,3)=-cosd(w)*sind(phi)*cosd(ka)+sind(w)*sind(ka);
m(i+1,1)=-cosd(phi)*sind(ka) ;
m(i+1,2)=-sind(w)*sind(phi)*sind(ka)+cosd(w)*cosd(ka) ;
m(i+1,3)=cosd(w)*sind(phi)*sind(ka)+sind(w)*cosd(ka);
m(i+2,1)=sind(phi);
m(i+2,2)=-sind(w)*cosd(phi);
m(i+2,3)=cosd(w)*cosd(phi);
% M=nan(4320,3);
M=[m(i,1) m(i,2) m(i,3);m(i+1,1) m(i+1,2) m(i+1,3);m(i+2,1) m(i+2,2) m(i+2,3)];
Axi=EIP(i,7)*m(i,1)+xmm1(i,1)*m(i+2,1); Bxi=EIP(i,7)*m(i,2)+xmm1(i,1)*m(i+2,2); Cxi=EIP(i,7)*m(i,3)+xmm1(i,1)*m(i+2,3); % compute parameteres
Ayi=EIP(i,7)*m(i+1,1)+ymm1(i,1)*m(i+2,1); Byi=EIP(i,7)*m(i+1,2)+ymm1(i,1)*m(i+2,2); Cyi=EIP(i,7)*m(i+1,3)+ymm1(i,1)*m(i+2,3);
Lxi=Axi*EIP(i,1)+Bxi*EIP(i,2)+Cxi*EIP(i,3);
Lyi=Ayi*EIP(i,1)+Byi*EIP(i,2)+Cyi*EIP(i,3);
end
Sir, now I want arrange the results in a specific matrices
bashar halleem
bashar halleem am 21 Mai 2020
A matrix [Ax1 Bx1 Cx1 0 0 0
Ay1 By1 Cy1
. . . . . .
Ax12 Bx12 Cx12
Ay12 By12 Cy12 0 0 0
0 0 0 Ax13 Bx13 Cx13
0 0 0 Ay13 By13 Cy13
. . .
Ax24 Bx24 Cx24
0 0 0 Ay24 By24 Cy24
.
.
.
.
.
Ax108 Bx108 Cx108
Ay108 By108 Cy108
. . .
Ax120 Bx120 Cx120
Ay120 By120 Cy120 ]

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Stephen23
Stephen23 am 20 Mai 2020
Bearbeitet: Stephen23 am 20 Mai 2020
Having lots of numbered variables is not a good approach, you should place all of those sub-matrices into one cell array when they are created (this is trivial using indexing), i.e.:
C = {M1,M2,... };
where
M1 = [Ax1,Bx1,Cx1;Ay1,By1,Cy1,...];
etc. Of course you should just use indexing when you create them, and NOT use numbered variable names,
Then all you need is one simple blkdiag call:
B = blkdiag(C{:});
If there is actually just one submatrix repeated (as your question shows), then you can do this:
C = {M};
B = blkdiag(C{ones(1,144)});

Community Treasure Hunt

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

Start Hunting!

Translated by