How to replace a categorical label by another label if the label satisfies a condition?

5 visualizaciones (últimos 30 días)
I have a 1872x1 cell data where each cell comprises 1x5000 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 1872x1 cell-mat file.
The first element of the cell.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 13 de Dic. de 2023
Editada: Dyuman Joshi el 13 de Dic. de 2023
Here's an approach, but it does not take into account if there's a starting group with number of elements less than a given positive integer.
You can make it a function and run a for loop through the 5 cells.
load('labelsSample.mat')
in = labelsSample{1};
%Find the groups of the categorical values
[z, vec] = findgroups(in)
z = 1×5000
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4
vec = 1×4 categorical array
P QRS T n/a
%Threshold for comparison
n=5;
%% Find the indices of the groups that are <= threshold
%Indices where the group changes
idx = find([false diff(z)~=0])
idx = 1×169
30 84 117 130 152 200 246 259 264 286 319 333 356 400 459 476 507 524 543 586 645 664 692 708 729 766 832 855 884 896
%Checking for groups which has <= n elements
k = diff(idx)<=n;
%Groups
index=[idx([k false]);idx([false k])].'
index = 11×2
259 264 2744 2747 2747 2748 2748 2753 2753 2758 2953 2954 2954 2958 2958 2961 2961 2963 4059 4061
%Modify the groups according to previous group
for n = 1:size(index,1)
z(index(n,1):index(n,2)) = z(index(n,1)-1);
end
%Convert back the output to categorical array using indexing
out = vec(z)
out = 1×5000 categorical array
Columns 1 through 28 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 29 through 50 T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 51 through 72 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 73 through 97 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P P P P Columns 98 through 123 P P P P P P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a Columns 124 through 145 n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 146 through 167 QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 168 through 189 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 190 through 214 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T Columns 215 through 242 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 243 through 264 T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 265 through 286 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P Columns 287 through 314 P P P P P P P P P P P P P P P P P P P P P P P P P P P P Columns 315 through 336 P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS Columns 337 through 358 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a Columns 359 through 380 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 381 through 402 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T Columns 403 through 430 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 431 through 458 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 459 through 481 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P Columns 482 through 508 P P P P P P P P P P P P P P P P P P P P P P P P P n/a n/a Columns 509 through 530 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS Columns 531 through 552 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 553 through 574 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 575 through 599 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T Columns 600 through 627 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 628 through 652 T T T T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a Columns 653 through 677 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P P P P Columns 678 through 702 P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 703 through 724 n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 725 through 746 QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 747 through 768 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T Columns 769 through 796 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 797 through 824 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 825 through 847 T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 848 through 873 n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P P P P P P P P P Columns 874 through 897 P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS Columns 898 through 919 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a Columns 920 through 941 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 942 through 964 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T Columns 965 through 992 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 993 through 1017 T T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1018 through 1039 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1040 through 1067 P P P P P P P P P P P P P P P P P P P P P P P P P P P P Columns 1068 through 1089 P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS Columns 1090 through 1111 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a Columns 1112 through 1133 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1134 through 1157 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T Columns 1158 through 1185 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 1186 through 1213 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 1214 through 1235 T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1236 through 1263 P P P P P P P P P P P P P P P P P P P P P P P P P P P P Columns 1264 through 1285 P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS Columns 1286 through 1307 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a Columns 1308 through 1329 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1330 through 1351 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T Columns 1352 through 1379 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 1380 through 1404 T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1405 through 1426 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1427 through 1450 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P Columns 1451 through 1476 P P P P P P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a Columns 1477 through 1498 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 1499 through 1520 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1521 through 1542 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1543 through 1566 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T Columns 1567 through 1592 T T T T T T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a Columns 1593 through 1614 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1615 through 1636 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P Columns 1637 through 1664 P P P P P P P P P P P P P P P P P P P P P P P P P P P P Columns 1665 through 1686 P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS Columns 1687 through 1708 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a Columns 1709 through 1730 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 1731 through 1755 n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T T Columns 1756 through 1783 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 1784 through 1810 T T T T T T T T T T T T T T T T T T T T T T T T T T n/a Columns 1811 through 1833 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P Columns 1834 through 1860 P P P P P P P P P P P P P P P P P P P P P P P P P n/a n/a Columns 1861 through 1882 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 1883 through 1904 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a Columns 1905 through 1929 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T Columns 1930 through 1957 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 1958 through 1985 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 1986 through 2010 T T T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2011 through 2035 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P P P P P Columns 2036 through 2059 P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2060 through 2081 n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 2082 through 2103 QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2104 through 2125 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2126 through 2151 n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T T T T T T T Columns 2152 through 2179 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 2180 through 2201 T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2202 through 2225 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P Columns 2226 through 2251 P P P P P P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a Columns 2252 through 2273 n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 2274 through 2295 QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2296 through 2317 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2318 through 2343 n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T T T T T Columns 2344 through 2367 T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2368 through 2389 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2390 through 2414 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P P P P Columns 2415 through 2439 P P P P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a Columns 2440 through 2461 n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 2462 through 2483 QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2484 through 2505 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2506 through 2533 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 2534 through 2561 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 2562 through 2587 T T T T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a P Columns 2588 through 2615 P P P P P P P P P P P P P P P P P P P P P P P P P P P n/a Columns 2616 through 2637 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS Columns 2638 through 2659 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a Columns 2660 through 2681 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2682 through 2707 n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T T T T T T Columns 2708 through 2735 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 2736 through 2762 T T T T T T T T T T T T T T T T T T T T T T T n/a n/a n/a n/a Columns 2763 through 2785 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P Columns 2786 through 2812 P P P P P P P P P P P P P P P P P P P P P P P P n/a n/a n/a Columns 2813 through 2834 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 2835 through 2856 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a Columns 2857 through 2878 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2879 through 2903 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T Columns 2904 through 2931 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 2932 through 2959 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 2960 through 2981 T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 2982 through 3008 n/a n/a n/a P P P P P P P P P P P P P P P P P P P P P P P P Columns 3009 through 3032 P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS Columns 3033 through 3054 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 3055 through 3076 QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3077 through 3099 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T Columns 3100 through 3127 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 3128 through 3154 T T T T T T T T T T T T T T T T T T T T T T T T T T n/a Columns 3155 through 3176 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3177 through 3203 n/a n/a P P P P P P P P P P P P P P P P P P P P P P P P P Columns 3204 through 3226 P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS Columns 3227 through 3248 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 3249 through 3270 QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3271 through 3292 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3293 through 3319 n/a n/a n/a T T T T T T T T T T T T T T T T T T T T T T T T Columns 3320 through 3347 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 3348 through 3372 T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P Columns 3373 through 3399 P P P P P P P P P P P P P P P P P P P P P P P P n/a n/a n/a Columns 3400 through 3421 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 3422 through 3443 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3444 through 3465 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3466 through 3489 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T Columns 3490 through 3517 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 3518 through 3544 T T T T T T T T T T T T T T T T T T T T T T T T n/a n/a n/a Columns 3545 through 3571 n/a n/a n/a n/a P P P P P P P P P P P P P P P P P P P P P P P Columns 3572 through 3595 P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3596 through 3617 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a Columns 3618 through 3639 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3640 through 3663 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T T T Columns 3664 through 3691 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 3692 through 3719 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 3720 through 3745 T T n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P P P P P P P Columns 3746 through 3769 P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3770 through 3791 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a Columns 3792 through 3813 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3814 through 3836 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T Columns 3837 through 3864 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 3865 through 3891 T T T T T T T T T T T T T T T T T T T T T T T T T n/a n/a Columns 3892 through 3915 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P P P P P P P P Columns 3916 through 3941 P P P P P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a Columns 3942 through 3963 n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 3964 through 3985 QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 3986 through 4007 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4008 through 4034 n/a n/a T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4035 through 4062 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4063 through 4087 T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P Columns 4088 through 4115 P P P P P P P P P P P P P P P P P P P P P P P P P P P P Columns 4116 through 4137 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS Columns 4138 through 4159 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a Columns 4160 through 4181 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4182 through 4208 n/a n/a n/a n/a T T T T T T T T T T T T T T T T T T T T T T T Columns 4209 through 4236 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4237 through 4262 T T T T T T T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a Columns 4263 through 4289 n/a n/a n/a n/a P P P P P P P P P P P P P P P P P P P P P P P Columns 4290 through 4312 P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4313 through 4334 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a Columns 4335 through 4356 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4357 through 4378 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T Columns 4379 through 4406 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4407 through 4434 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4435 through 4462 T T T T T T T T T T T T T T T T P P P P P P P P P P P P Columns 4463 through 4487 P P P P P P P P P P P P P P P P n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4488 through 4509 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 4510 through 4531 QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4532 through 4553 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4554 through 4579 n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T T T T T T Columns 4580 through 4607 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4608 through 4632 T T T T T T T T T T T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P Columns 4633 through 4660 P P P P P P P P P P P P P P P P P P P P P P P P P P P P Columns 4661 through 4682 P P n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS Columns 4683 through 4704 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a Columns 4705 through 4726 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4727 through 4750 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a T T T T T T T T T Columns 4751 through 4778 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4779 through 4806 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4807 through 4829 T T T T n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a P P P Columns 4830 through 4856 P P P P P P P P P P P P P P P P P P P P P P P n/a n/a n/a n/a Columns 4857 through 4878 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a QRS QRS QRS QRS QRS QRS QRS QRS QRS Columns 4879 through 4900 QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS QRS n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4901 through 4922 n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a n/a Columns 4923 through 4948 n/a n/a n/a n/a n/a n/a T T T T T T T T T T T T T T T T T T T T Columns 4949 through 4976 T T T T T T T T T T T T T T T T T T T T T T T T T T T T Columns 4977 through 5000 T T T T T T T T T T T T T T T T T T T T T n/a n/a n/a
  3 comentarios
Dyuman Joshi
Dyuman Joshi el 14 de Dic. de 2023
What if the next group of the starting group is also to be modified?
Say the sequence is - [T T P P QRS QRS QRS ....] with the threshold being 2.
What should be done here?
Should the output be [QRS QRS QRS QRS QRS QRS QRS ....] ?
Mibang
Mibang el 14 de Dic. de 2023
Thanks, Dyuman,
A sharp question. But, if you look into the sequences, that almost doesn't happen in this specific sampled electrocardiogram (ECG)-signal.
I realized that I need to cut off the initial dozens of samples as a stabiling period of the signal.
So, I think your code is perfect enough for my purpose, which I really appreciate.
Best,

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by