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

15 visualizzazioni (ultimi 30 giorni)
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 Commenti
Benjamin Thompson
Benjamin Thompson il 24 Gen 2023
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
Modificato: Shiv Nileshkumar Matliwala il 25 Gen 2023
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]

Accedi per commentare.

Risposta accettata

Tushar Behera
Tushar Behera il 1 Feb 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

Più risposte (0)

Categorie

Scopri di più su Cell Arrays in Help Center e File Exchange

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by