How to take output from one program as input in the same?
1 view (last 30 days)
Show older comments
Varun Shrishail Soraganvi
on 19 Dec 2021
Commented: Varun Shrishail Soraganvi
on 21 Dec 2021
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
0 Comments
Accepted Answer
Jan
on 19 Dec 2021
Edited: Jan
on 19 Dec 2021
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).
More Answers (0)
See Also
Categories
Find more on Robotics System Toolbox 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!