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

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 日

2 投票

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

1 件のコメント

Varun Shrishail Soraganvi
Varun Shrishail Soraganvi 2021 年 12 月 21 日
Thanks, I will try this. This helps a lot :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by