Multiplying matrices and vectors in loop

조회 수: 3 (최근 30일)
Tea Arrigoni
Tea Arrigoni 2017년 12월 14일
댓글: Tea Arrigoni 2017년 12월 14일
This is the part of the code I want to solve but it gives me error, says that the matrix size are not the same but they are all 3 x 3. Do I need a for loop maybe? Can you help with it?
clear all, clc; H=1700 %height
dSG=0.129*H;
dH=0.185*H;
dF=0.146*H;
FiA = -10:20:170 ;
FiFm = -60:10:170 ;
FiRm=-60:20:90;
FiEF=-90:20:60;
COSA=cosd(FiA);
SINA=sind(FiA);
RA = arrayfun( @(sinFif, cosFif) [cosFif 0 sinFif; 0 1 0; -sinFif 0 cosFif], SINA, COSA, 'uniform', 0)
CA=cell2mat(RA)
COSE=cosd(FiEF);
SINE=sind(FiEF);
RE = arrayfun( @(sinFif, cosFif) [cosFif 0 sinFif; 0 1 0; -sinFif 0 cosFif], SINE, COSE, 'uniform', 0)
CE=cell2mat(RE)
[gFiA, gFiFm] = ndgrid(FiA, FiFm);%you want all combinations
gFiF = gFiFm + gFiA / 3 ;
COSF = cosd(gFiF); %cosd and sind because you are working in degrees !
SINF = sind(gFiF );
RF = arrayfun( @(sinFif, cosFif) [1 0 0; 0 cosFif -sinFif; 0 sinFif cosFif], SINF, COSF, 'uniform', 0)
CF=cell2mat(RF)
rSG=[-dSG 0 0]'; %shoulder joint - torso
rH=[0 0 -dH]' ;% upper arm
rF=[0 dF 0]';%fore arm
rW=rSG+CA*CF*rH+CE*rF

채택된 답변

KL
KL 2017년 12월 14일
they are all 3 x 3...
No, they are not. Check the output for the following
size(CA)
size(CF)
and the other matrices you have.
Just copy-pasting the code doesn't help either. What exactly do you want to do?
  댓글 수: 1
Tea Arrigoni
Tea Arrigoni 2017년 12월 14일
That is correct. Sorry for that. I am relatively new in Matlab. I will send you in the attachment what I need but in short I need to recreate all point that a human wrist can reach in workspace for an exoskeleton-rehabilitation device we are trying to build (My PhD). I have three angles in shoulder FiA, FiF and FiR, and I have one FiEF in elbow and in correlation of shoulder and elbow movement I want to get a cloud of points in a workspace. I have all formulas but I have to make the whole iteration i MatLab. I managed to compute point by point (just tested it) but I need it for the whole area. The formulas you can see attached. Can you help regarding this issue?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by