how can i multiply 2 matrices with different dimension ?

5 次查看(过去 30 天)
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 个评论
ladan hz
ladan hz 2017-10-26
编辑:Walter Roberson 2017-10-26
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 2017-10-26
You are overwriting all of AnVel every iteration of the "for" loop. It seems unlikely that is what you want to do.

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2017-10-25
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 个评论
ladan hz
ladan hz 2017-10-26
编辑:Walter Roberson 2017-10-26
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

请先登录,再进行评论。


KSSV
KSSV 2017-10-25
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