how to compare a row of the table with other rows of that table itself for the particular Columns ?
27 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Shiv Nileshkumar Matliwala
le 24 Jan 2023
Modifié(e) : Shiv Nileshkumar Matliwala
le 16 Mai 2023
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 commentaires
Benjamin Thompson
le 24 Jan 2023
Can you attach the sample table to this post as a MAT file and list the exact output you are looking for?
Réponse acceptée
Tushar Behera
le 1 Fév 2023
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!