How to automate a process?

1 view (last 30 days)
Sebastian Ciuban
Sebastian Ciuban on 2 May 2013
  • Note: English is not my first language and I may be not very explicit.
I have the input data:- matrix A(3,2)=[683265.032 465089.623; 683248.660 464977.521; 683303.746 465039.114].
-_Function ,,Orientation"_ which contains this formula: *atan((B(1,2)-A(1,2))/(B(1,1)-A(1,1)))*200/pi*.
And this matrix B(3,3)-output data: B=[-1 Orientation(A(1,:),A(2,:)) Orientation(A(1,:),A(3,:)); Orientation(A(2,:),A(1,:)) -1 Orientation(A(2,:),A(3,:)); Orientation(A(3,:),A(1,:)) Orientation(A(3,:),A(2,:)) -1];
  • "-1" means that Orientation to the same point can't be calculated.
So far so good by now. But what if I want to add 2 more rows of coordinates in matrix A? I want matrix B to calculate, using function "Orientation", regardless of how many sets of coordinates matrix A contains (rows). I don't want to write manually the commands in B every time I add new data to A. It is possible to automate this process?
  2 Comments
Jan
Jan on 2 May 2013
The question is not clear. Are the functions "Orientation" and "Orientare" identical?
Sebastian Ciuban
Sebastian Ciuban on 2 May 2013
Yes they are. Sorry, my mistake

Sign in to comment.

Accepted Answer

Jan
Jan on 2 May 2013
I do not understand the question completely. Perhaps you are looking for:
function R = Orientation(A, B)
R = atan((B(:, 2) - A(:, 2)) ./ (B(:,1) - A(:,1))) * (200/pi);
  1 Comment
Sebastian Ciuban
Sebastian Ciuban on 2 May 2013
In my example i have A(3,2) and the calculated matrix B(3,3) with the function Orientation. I want to make matrix B to be calculated regardless of number of lines that matrix A have.
for A(n,2) I want B(n,n) to be calculated with that function

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!