how to find the first column's values regarding to second column?

조회 수: 1 (최근 30일)
bilgesu ak
bilgesu ak 2016년 3월 29일
댓글: Joachim Schlosser 2016년 3월 31일
Hi;
I have a CZ matrix that changes iteratively (according to an assignment logic) like given below. First column shows task numbers and second column shows station numbers that regarding tasks assigned.
CZ =
1 1
4 2
CZ =
1 1
4 2
5 2
CZ =
1 1
4 2
5 2
3 3
CZ =
1 1
4 2
5 2
3 3
2 3
CZ =
1 1
4 2
5 2
3 3
2 3
6 4
CZ =
1 1
4 2
5 2
3 3
2 3
6 4
7 4
I want to look every station's tasks after every CZ. For example first CZ constists station 1 as closed station. Also station 2 exists in first CZ but we don't know it is closed or not. and only task 1 is assigned to station 1. I want to obtain task 1. In second CZ we dont know station 2 is closed or open so the code should give the tasks if the station is closed. After third CZ it should give task 4 and task 5 for station 2 and so on...
How should I make this?
Regards...
  댓글 수: 3
bilgesu ak
bilgesu ak 2016년 3월 30일
if there is not enough time at that staion (according to the cycle time) it means that no more tasks can be assign so that station is closed and next station is opened...
Image Analyst
Image Analyst 2016년 3월 30일
Clear as mud. And just where are we supposed to find either the "time at that station" or the "cycle time"?

댓글을 달려면 로그인하십시오.

답변 (1개)

Joachim Schlosser
Joachim Schlosser 2016년 3월 29일
If you are looking to get the assignments for each station specified in column 2, then the following code will do:
cztab = table(CZ(:,2),CZ(:,1))
czbucket = splitapply(@(x1){horzcat(x1)},cztab.Var2,findgroups(cztab.Var1))
czbucket{:}
The last command simply shows the buckets for each station.
  댓글 수: 2
bilgesu ak
bilgesu ak 2016년 3월 30일
I applied your code under CZ in my code but program gave an error that Undefined function or method 'table' for input arguments of type 'double'
Joachim Schlosser
Joachim Schlosser 2016년 3월 31일
What release of MATLAB are you using? The table class exists in MATLAB since R2013b, so I suggest upgrading.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by