필터 지우기
필터 지우기

how to compare a row of the table with other rows of that table itself for the particular Columns ?

조회 수: 30 (최근 30일)
Suppose I have a table as below,
Now, in the above table first I want to check the TaskAssignment value. If it is 'Separated' then I want to store the Index value of that row into one array for example in above as an output i need to store index value 1 and 2 in an array called 'Configure1'
Now after checking the TaskAssignment, I want to focus now only on TaskAssignment = 'Summarized' rows.
Here, now first I need to check the TaskPriority for that all fours rows who has value TaskAssignment = 'Summarized', if there more than one TaskPriority which is the case above, I need to make group of that rows. so there will be two groups of TaskPriority '30' and '31' and now I want to check the 'EventType' value for these groups one by one. and if that values are equal which is the case above then I want check for the 'Period' value of that group rows. If both 'EventType' and 'Period' for the group of TaskPriority = '30' then I want to store index of that rows in one variable 'Group' and then stored the same index value which is 4 and 6 to 'Configure2' array.
Now if there are two rows in one group then if any value of 'EventType' and 'Period' of those two rows are different then I need to concatanet those row's index value for example 4 and 6 to 'Configure1'
if there are more than two rows in one group then the row which has the different value for 'EventType' and 'Period' compare to two other rows with same value then again I want to add the Index value of that row to 'Configure1' and all the other rows who has same values, thier index values will go to 'Configure2'
It is actually a bit complicated. I hope you have understood what i am trying to explain here.
  댓글 수: 2
Benjamin Thompson
Benjamin Thompson 2023년 1월 24일
Can you attach the sample table to this post as a MAT file and list the exact output you are looking for?
Shiv Nileshkumar Matliwala
Shiv Nileshkumar Matliwala 2023년 1월 25일
편집: Shiv Nileshkumar Matliwala 2023년 1월 25일
Yes, I can attache the file here.
Here we just need to focus on the four columns which are TaskAssignment --> TaskPriority --> EventType --> Period wiht this respective order.
As an outut I should have two arrays Config1 and Config2
Config1 = [3,7] , Config2 = [1,2,5,4,6]

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

채택된 답변

Tushar Behera
Tushar Behera 2023년 2월 1일
Hi Shiv,
I believe what you are looking for is first to group your data according to "TaskAssignment" and then for "TaskAssignment" which has the value "Summarized" you want to group them based on "TaskPriority" and eventually group them based on "EventType" and "Period". Given that "EventType" and "Period" should e looked upon simultaneously. After which you want their row indexes in two separate arrays.
This can be achieved by using functions such as "findgroups", this will give you an array of group indexes that are equal in value.
findgroups(yourtable.TaskPriority)
Also you can leverage functions like "ismember" and "find" which can give you row indexes for given variable value,
for example,
config=ismember(descr_table.TaskAssignment,'Separated')%group all the separated
config1=find(config==1)
%where inside config 1 you will find the row indexes
config1 =
1
2
For the complete workflow, you can refer to the following link,
I hope this resolves your query.
Regards,
Tushar

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by