Issue in defining range and getting all possible iterations

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

1 Comment

Rather than putting a blank line between each line of code that hardly makes the code readable, paste your code, select it, then press the {}Code button. It will be a lot easier to read.

Sign in to comment.

 Accepted 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.

3 Comments

Did you mean something like this? It gives me error in a row where the Ram calculation begins. The part where Matlab has to calculate the Matrix of function RAm that is in corelation with fiAm I get error saying:
??? Error using ==> vertcat CAT arguments dimensions are not consistent. The rWm that I need is a sum of matrix and vector of all posibilities of Matrix that depend on the angles and then I get all kine of points in space. I tried it by hand writing one point by one but takes me a long time to do so.
Error in ==> TEST_365 at 19 RAm=[COSAm 0 SINAm;0 1 0;-SINAm 0 COSAm] %Elevation through ABDUCTION-ADDUCTION - about axis y
The code is here belowe.
clear all, close all, clc;
axes('NextPlot', 'add');
H=1700 %Visina osobe u mm
dSG=0.129*H % Duzina ramenog dijela od torza do ramenog zgloba
dH=0.185*H % Duzina nadlaktice
dF=0.146*H % Duzina podlaktice
%PRORACUN POZICIJE TOCKE WR ZA NAJNIZE VRIJEDNOSTI RANGE-A
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
COSAm=cosd(fiAm)
SINAm=sind(fiAm)
RAm=[COSAm 0 SINAm;0 1 0;-SINAm 0 COSAm] %Elevation through ABDUCTION-ADDUCTION - about axis y
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
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
COSEFm=cosd(fiEFm)
SINEFm=sind(fiEFm)
REFm=[1 0 0; 0 COSEFm -SINEFm; 0 SINEFm COSEFm] %Elbow flexion -extension - about axis x
%segmentni vektori - transponirane matrice
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+')
end
end
end
The code by itself goes great with" for" loop inseide (if I comment all variables like RFm, RRmm, REFm..) but when I want to calculate matrix with it then it just stops.
Perhaps you do not want fiAm to be a vector? Then replace:
fiAm = 0:20:180; % RANGE from -10 to 170 deg ??? 0:20:180 is not "-10:10:170" ?!?
by
for fiAm = 0:20:180
...
end
Note: It is a good programming practice to use functions to keep the workspace clean. This is much better than the brutal clearing header "clear all, close all, clc;" . Especially clear all wastes time and energy, because it removes all functions from the RAM and reloading them from the slow disk takes time.

Sign in to comment.

More Answers (0)

Asked:

on 18 Dec 2017

Edited:

Jan
on 21 Dec 2017

Community Treasure Hunt

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

Start Hunting!