How to take output from one program as input in the same?

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Jan
Jan il 19 Dic 2021
Modificato: Jan il 19 Dic 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).

Più risposte (0)

Categorie

Scopri di più su Robotics System Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by