필터 지우기
필터 지우기

how can i multiply 2 matrices with different dimension ?

조회 수: 5 (최근 30일)
ladan hz
ladan hz 2017년 10월 25일
댓글: Walter Roberson 2017년 10월 26일
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?

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by