MATLAB: Issue in defining range and getting all possible iterations

matrixworkspace

clear all, close all, clc;
H=1700 %Height of person
dSG=0.129*H
dH=0.185*H
dF=0.146*H
%POSITION OF POINT IN SPACE
fiAm=0:20:180; % RANGE from -10 to 170 deg
COSAm=cosd(fiAm)
SINAm=sind(fiAm)
RAm=[COSAm 0 SINAm;0 1 0;-SINAm 0 COSAm] %Elevation through ABDUCTION-ADDUCTION - about axis y
fiFm=-60 % rotacija oko y ramenog zgloba - RANGE from -60 to 170
fiFmm=fiFm+fiAm/3
COSFmm=cosd(fiFmm)
SINFmm=sind(fiFmm)
RFm=[1 0 0;0 COSFmm -SINFmm;0 SINFmm COSFmm] % Evelation through FLEXION-EXTENSION - about axis x
fiRm=-60 % RANGE -60 to 170 deg
fiRmm=fiRm+7*fiAm/9-fiFmm/9
COSRmm=cosd(fiRmm)
SINRmm=sind(fiRmm)
RRmm=[COSRmm -SINRmm 0; SINRmm COSRmm 0;0 0 1] % Internal-external rotation - ybout axis z
fiEFm=-90; % RANGE from -90 until 60 deg
COSEFm=cosd(fiEFm)
SINEFm=sind(fiEFm)
REFm=[1 0 0; 0 COSEFm -SINEFm; 0 SINEFm COSEFm] %Elbow flexion -extension - about axis x
%segment vectors
rSG=[-dSG 0 0]'
rH=[0 0 -dH]'
rF=[0 dF 0]'
rWm=rSG+RRmm*RAm*RFm*rH+REFm*rF
plot3(rWm(1),rWm(2),rWm(3),'k+')
grid on;
Can you help me so I can get a number of iterations so I don't have to change by hand al possibilities of the range angles of fiAm, fiFm, fiRm and FiEFm. I wanted to change its range by 10 degrees and get a number of points in the space. Is it possible

Best Answer

As far as I understand all you need is:
axes('NextPlot', 'add'); % see: hold('on')
...
%POSITION OF POINT IN SPACE
fiAm = 0:20:180; % RANGE from -10 to 170 deg ??? 0:20:180 is not "-10:10:170" ?!?
for fiFm = -60:10:170
for fiRm = -60:10:170
for fiEFm = -90:10:60
... Your computations here without redefining fiFm, fiRm, fiEFm
plot3(rWm(1), rWm(2), rWm(3), 'k+')
end
end
end
In your code fiAm is a vector, but you ask for a loop: If this is needed, simply add a "for" as in the other lines.