Effacer les filtres
Effacer les filtres

how can i multiply 2 matrices with different dimension ?

5 vues (au cours des 30 derniers jours)
ladan hz
ladan hz le 25 Oct 2017
Commenté : Walter Roberson le 26 Oct 2017
i have Rr=3*3 matrices and PQRg=3*110 and i want to multiply them and get AnVel=[Rr]*[PQRg]which is 3*110 ? how is possible?
  3 commentaires
ladan hz
ladan hz le 26 Oct 2017
Modifié(e) : Walter Roberson le 26 Oct 2017
actually i want to do it in alopp and its not work :( thats the problem ,i know the law and its works outside of the loop :(
for i=1:111
xx=XG(:,i)/norm(XG(:,i));
yy=YG(:,i)/norm(YG(:,i));
zz= ZG(:,i)/norm(ZG(:,i));
Rr=[xx,yy,zz];
determinante=det(Rr);
time=[1:1:111]';
Time=time/120;
[R1 R2 R3]=dcm2angle (Rr); %[yaw, pitch, roll] = dcm2angle( dcm )
TableTeta(i,:)=[R2];
TableFi(i,:)=[R1];
TableAlfa(i,:)=[R3];
deFi= diff(TableFi);
deAlfa= diff(TableAlfa);
deTeta=diff(TableTeta);
%VELOCITà ANGOLARE
Pg=(deAlfa*sin(TableFi(i,:))*sin(TableTeta(i,:))+deFi*cos(TableTeta(i,:))).*120;
Qg=(deAlfa*sin(TableFi(i,:))*cos(TableTeta(i,:))-deFi*sin(TableTeta(i,:))).*120;
Rg=(deAlfa*cos(TableFi(i,:))+deTeta).*120;
PG=Pg';
QG=Qg';
RG=Rg';
PQRg=[PG; QG; RG]
AnVel1=Rr*PQRg;
AnVel=[AnVel1]';
end
Walter Roberson
Walter Roberson le 26 Oct 2017
You are overwriting all of AnVel every iteration of the "for" loop. It seems unlikely that is what you want to do.

Connectez-vous pour commenter.

Réponses (2)

John D'Errico
John D'Errico le 25 Oct 2017
Um, read the getting started tutorials?
AnVel = Rr*PQRg;
It is legal to read the documentation. You might even learn how to use the language.
  1 commentaire
ladan hz
ladan hz le 26 Oct 2017
Modifié(e) : Walter Roberson le 26 Oct 2017
sorry but this is not working inside a loop which i send you the loop now ??
for i=1:111
xx=XG(:,i)/norm(XG(:,i));
yy=YG(:,i)/norm(YG(:,i));
zz= ZG(:,i)/norm(ZG(:,i));
Rr=[xx,yy,zz];
determinante=det(Rr);
time=[1:1:111]';
Time=time/120;
[R1 R2 R3]=dcm2angle (Rr); %[yaw, pitch, roll] = dcm2angle( dcm )
TableTeta(i,:)=[R2];
TableFi(i,:)=[R1];
TableAlfa(i,:)=[R3];
deFi= diff(TableFi);
deAlfa= diff(TableAlfa);
deTeta=diff(TableTeta);
%VELOCITà ANGOLARE
Pg=(deAlfa*sin(TableFi(i,:))*sin(TableTeta(i,:))+deFi*cos(TableTeta(i,:))).*120;
Qg=(deAlfa*sin(TableFi(i,:))*cos(TableTeta(i,:))-deFi*sin(TableTeta(i,:))).*120;
Rg=(deAlfa*cos(TableFi(i,:))+deTeta).*120;
PG=Pg';
QG=Qg';
RG=Rg';
PQRg=[PG; QG; RG]
AnVel1=Rr*PQRg;
AnVel=[AnVel1]';
end

Connectez-vous pour commenter.


KSSV
KSSV le 25 Oct 2017
YOu can happily multiply them using *.
Rr = rand(3,3) ;
PQRg = rand(3,110) ;
P = Rr*PQRg
Remmember multiplication law?

Community Treasure Hunt

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

Start Hunting!

Translated by