Use of 3D array. Find inverse of individual page
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
My program contains a 3x3x100 matrix. I need to find A=J\B where J is each page of the 3x3x100 matrix ( i.e. 100 numbers of 3x3 matrix) and B is a 3x1 matrix. Which would result in matrix A to be of dimension 3x100
How do i solve this. One of the ways might be to generate a loop 100 times. But i was looking for more efficient way. May by using the matrix directly. Please help.
I have attached the codes incase it helps.
function[J]=Jacobian(t1,t2,t3)
global l1 l2 l3;
%t1 t2 and t3 would be 1x100 matrices each.
J{1,1}=-(l1+l2.*cos(t2)+l3.*cos(t2+t3)).*sin(t1);
J{1,2}=-(l2.*sin(t2)+l3.*sin(t2+t3)).*cos(t1);
J{1,3}=-l3.*sin(t2+t3).*cos(t1);
J{2,1}=(l1+l2.*cos(t2)+l3.*cos(t2+t3)).*cos(t1);
J{2,2}=-(l2.*sin(t2)+l3.*sin(t2+t3)).*sin(t1);
J{2,3}=-l3.*sin(t2+t3).*sin(t1);
J{3,1}=0;
J{3,2}=l2.*cos(t2)+l3.*cos(t2+t3);
J{3,3}=l3.*cos(t2+t3);
function[]=Support(A,B)
%.....
J=Jacobian(M1(1,:),M1(2,:),M1(3,:))
vx=(B(1)-A(1))/2.5
vy=0;
vz=0;
V=[vx;vy;vz];
Td=J\V
This is the error i get
??? Undefined function or method 'mldivide' for input arguments of type 'cell'.
Error in ==> Support at 11 Td=J\V
0 commentaires
Réponse acceptée
Andrei Bobrov
le 8 Juin 2011
function J =Jacobian1(t)
global l1 l2 l3;
j1 = [-(l1+l2.*cos(t(2,:))+l3.*cos(t(2,:)+t(3,:))).*sin(t(1,:));
-(l2.*sin(t(2,:))+l3.*sin(t(2,:)+t(3,:))).*cos(t(1,:));
-l3.*sin(t(2,:)+t(3,:)).*cos(t(1,:));
(l1+l2.*cos(t(2,:))+l3.*cos(t(2,:)+t(3,:))).*cos(t(1,:));
-(l2.*sin(t(2,:))+l3.*sin(t(2,:)+t(3,:))).*sin(t(1,:));
-l3.*sin(t(2,:)+t(3,:)).*sin(t(1,:));
zeros(1,size(t,2));
l2.*cos(t(2,:))+l3.*cos(t(2,:)+t(3,:));
l3.*cos(t(2,:)+t(3,:))];
J = permute(reshape(j1,3,3,[]),[2 1 3]);
end
J=Jacobian1(M1);
vx=(B(1)-A(1))/2.5;
vy=0;
vz=0;
V=[vx;vy;vz];
Td=cell2mat(arrayfun(@(jj)J(:,:,jj)\V,1:size(J,3),'un',0));
2 commentaires
Plus de réponses (1)
James Tursa
le 9 Juin 2011
See this small size linear solver by Bruno Luong:
and you might be interested in this one as well:
0 commentaires
Voir également
Catégories
En savoir plus sur Descriptive Statistics dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!