create cell array containing neighbour element
이전 댓글 표시
Hi,
i have a matrix gnbh(ngex2). My first column gives me the index in -x direction and my second in +x direction.
I start with first_element = find(gnbh(:,1)==0)
now i want to add to a matrix my second_element = gnbh(first_element,2) for each first element in a row. my third element will be
third_element = gnbh(second_element,2) and fourth_element = gnbh(third_element,2) and so on.
input = gnbh(ngaps,2)
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 0
1 18
2 19
3 20
4 21
5 -1
6 0
7 22
8 23
10 24
11 25
12 26
13 27
16 29
17 30
18 31
19 32
20 33
21 34
-1 35
22 37
23 38
24 40
25 41
26 43
27 -1
28 44
0 45
29 46
30 47
0 48
31 0
32 49
0 50
33 -1
35 51
36 52
37 0
38 54
39 55
41 -1
42 -1
44 0
45 59
0 60
47 61
48 62
0 63
-1 0
0 65
52 66
53 67
54 0
55 69
attention: if the second column is 0 i will continue with the next cell array.
my output will be a cell where every cell matrix shows me my 1st element my 2nd and so on until the last element ) in a row
e.g. output = cell = number of first elements x 1
and every cell contains a row matrix starting with my 1st element e.g 1x1 = [1 10 18 25 32 41 0], 1x2 = [2 11 19 26 33 42 52 63 0]
댓글 수: 2
KALYAN ACHARJYA
2019년 11월 21일
Sorry, the question is still unclear to me? Could you please add small example with expected output?
bbah
2019년 11월 21일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!