Multiplying matrices and vectors in loop

2 views (last 30 days)
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

Accepted Answer

KL
KL on 14 Dec 2017
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 Comment
Tea Arrigoni
Tea Arrigoni on 14 Dec 2017
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?

Sign in to comment.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!