Clear Filters
Clear Filters

how can i multiply 2 matrices with different dimension ?

5 views (last 30 days)
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 Comments
ladan hz
ladan hz on 26 Oct 2017
Edited: Walter Roberson on 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 on 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.

Sign in to comment.

Answers (2)

John D'Errico
John D'Errico on 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 Comment
ladan hz
ladan hz on 26 Oct 2017
Edited: Walter Roberson on 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

Sign in to comment.


KSSV
KSSV on 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!