How to trace and extract the previous different case

1 view (last 30 days)

Hi,

I have below data(cell array), and I want to do the following,

name	        subname	      status   time
  TV0236.00	VR2300.01     pass	5
  TV0236.00	VI2300.02     pass      7
  TV0236.00	VI2300.03     redo	14
  TV0237.00	VR2300.02     redo	26
  TV0237.00	VR2300.03     pass	9
  TVD897.00	VF2300.01     pass	10
  TVD897.00	VF2300.02     pass	7
  TVD897.00	VF2300.03     redo	17
  TVD897.00	VF2300.04     pass	10
  TVD677.00	VF2300.05     redo	7
  GTY568.00	NU00897.01    redo	12
  GTY568.00	NU00897.02    pass	4
  GTY568.00	NU00897.03    pass	1
  BH0568.00	NU00897.04    pass	7
  GTY968.00	NU00897.05    redo	20

if the time>10, and status is 'redo', then extract the corresponding row of previous different name, I given examples below:

case1:
  row3 time>10, but there is no different name exist previously, the obvious one is row 2
    case2:
    in row4, time>10
    the previous different name is row3
    case3:
    row8 time>10
    the previous different case is row5 etc,

my desired outputs are; rows with time>10, and rows with corresponding previous different name

Out1: rows with time>10
TV0236.00	VI2300.03	redo	14
TV0237.00	VR2300.02	redo	26
TVD897.00	VF2300.03	redo	17
GTY568.00	NU00897.01	redo	12
GTY968.00	NU00897.05	redo	20
out2:rows corresponding to previous different names for time>10
TV0236.00	VI2300.02	pass	7
TV0236.00	VI2300.03	redo	14
TV0237.00	VR2300.03	pass	9
TVD677.00	VF2300.05	redo	7
BH0568.00	NU00897.04	pass	7

Many thanks in advance

  1 Comment
Image Analyst
Image Analyst on 15 Apr 2017
Make it easy for us to help you and give us code to get that cell array into our program so we can try thing. I'll check back tomorrow for it. By the way, why not use a table instead of a cell array?

Sign in to comment.

Answers (0)

Categories

Find more on Get Started with Statistics and Machine Learning Toolbox in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!