How to replace a categorical label by another label if the label satisfies a condition?
I have a 1872×1 cell data where each cell comprises 1×5000 categorical labels of 4 kinds (P, QRS, T, or n/a) (please, see the figures below).
I want to replace consecutive labels whose sequence number is less than m that is any positive integer (e.g. 2, 3, 4, …)
It is desired because a too-short sequence of a label is a wrong prediction.
For instance, if there is a sequence like: (… P P P T P P P…) where only one "T", then, T is replaced by the label "P" and we have (… P P P P P P P…).
So, the target label or labels are replaced by the one that precedes and follows the target label.
Another example can be (… T T T P P P T T T…) needs to become (… T T T T T T T T T …).
This process is required for the whole 5000 categorical labels over all cell elements.
The mat files look like the below as the screenshots and the mat file of the first 5 rows was attached for your reference that can be downloaded.
First five rows of the 1872×1 cell-mat file.
The first element of the cell.I have a 1872×1 cell data where each cell comprises 1×5000 categorical labels of 4 kinds (P, QRS, T, or n/a) (please, see the figures below).
I want to replace consecutive labels whose sequence number is less than m that is any positive integer (e.g. 2, 3, 4, …)
It is desired because a too-short sequence of a label is a wrong prediction.
For instance, if there is a sequence like: (… P P P T P P P…) where only one "T", then, T is replaced by the label "P" and we have (… P P P P P P P…).
So, the target label or labels are replaced by the one that precedes and follows the target label.
Another example can be (… T T T P P P T T T…) needs to become (… T T T T T T T T T …).
This process is required for the whole 5000 categorical labels over all cell elements.
The mat files look like the below as the screenshots and the mat file of the first 5 rows was attached for your reference that can be downloaded.
First five rows of the 1872×1 cell-mat file.
The first element of the cell. I have a 1872×1 cell data where each cell comprises 1×5000 categorical labels of 4 kinds (P, QRS, T, or n/a) (please, see the figures below).
I want to replace consecutive labels whose sequence number is less than m that is any positive integer (e.g. 2, 3, 4, …)
It is desired because a too-short sequence of a label is a wrong prediction.
For instance, if there is a sequence like: (… P P P T P P P…) where only one "T", then, T is replaced by the label "P" and we have (… P P P P P P P…).
So, the target label or labels are replaced by the one that precedes and follows the target label.
Another example can be (… T T T P P P T T T…) needs to become (… T T T T T T T T T …).
This process is required for the whole 5000 categorical labels over all cell elements.
The mat files look like the below as the screenshots and the mat file of the first 5 rows was attached for your reference that can be downloaded.
First five rows of the 1872×1 cell-mat file.
The first element of the cell. access cell, handling data, categorical data MATLAB Answers — New Questions