I have a program, which shows me the shortest path between two points. From A to B, for example there can be 5 points. The output I get are the coordinates of these 5 points. I need to send these coordinates to a robot that I am building. Is there a possibility where output of the function can be used as an input of another program where in I can calculate the angle the Robot has to turn at each point?
Like I want to calculate the angle at each coordinate without actually typing it. Do I have to do it manually or can the result coordinates can be directly taken as an input for angle calculatrion?
Any help is appreciated, thank you

 채택된 답변

Jan
Jan 2021년 12월 19일
편집: Jan 2021년 12월 19일
Of course this is possible. A trivial example:
function main
[a, b] = thePoints;
alpha = theAngle(a, b);
disp(alpha)
end
function [a, b] = thePoints()
a = rand(1, 3);
b = rand(1, 3);
end
function alpha = theAngle(a, b)
alpha = atan2(vecnorm(cross(a, b)), dot(a, b));
end
Note that this example uses the output of functions as input for other functions multiple times. Every code, which cannot be solved in a single line takes output of former commands as input to following commands (execpt if the jobs are independent).

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Robotics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by