MATLAB Answers


What is the best way to store different variables into 1 variable?

Steve 님이 질문을 제출함. 15 Oct 2019 8:19
최근 활동 Steve 님이 댓글을 추가함. 17 Oct 2019 20:06
I need to take a bunch of coordinate points that I have stored in a variable, and sort them in groups of the ten closest endpoint triplet groups to each other triplet. Then, I need to store them along with another group of coordinate points that correspond to the central points of each of these triplets. What's the best way to do this? The attached file contains all the (x,y) coordinates for the endpoint triplets (first 6 columns), and the central points (last two columns) Thanks in advance for your help!

  댓글 수: 0

로그인 to comment.

답변 수: 1

回答者: John D'Errico
2019 年 10 月 15 日 8:21
編集済み: John D'Errico
2019 年 10 月 15 日 8:23

Use a cell array. Or use a srruct. Either can store anything you put into it.
Here, a struct will allow you to store everything with a name attached to each field, so it will be arguably a better choice. And you can have arrays of structs.

  댓글 수: 5

표시 이전 댓글 수: 2
2019 年 10 月 16 日 11:06
That is just a temporary perpetual "if" place-holder Walter.
Walter Roberson
2019 年 10 月 16 日 17:30
You overwrite ascendIdx each iteration of the loop, so it is not clear why you would bother to do
ascendIdx(ascendIdx==pt) = []; %remove the pt point
It would make more sense if that was just after the sort()
2019 年 10 月 17 日 20:06
Could you give me an example of how you would set up the proper code?

로그인 to comment.

Translated by