MATLAB: How to display specific number string

columnsdisplayMATLABstring

Hello guys ! I need to import from a .csv and display only 10 numbers(bold ones) preceded by a certain 3 numbers(underlined) string, so this 10 numbers will we found with other value in a column more than one time but only the 3 number that precede are the same everytime. The column can contain 50 or more repetitive string of 3 numbers 21 22 23 with different afferent prices below.
The 3 numbers repetitive represent lot number and the following represent prices.
T = readtable('prices.csv');
B = T(:,2);
Example column no 2 from csv:
25.12
45.13
21
22
23
65.55
45.44
42.66
78.56
45.88
42.66
89.78
88.55
45.55
79.65
45.66
123.45
259.45
21.56
42.53
12.49
21
22
23
25.12
45.13
89.78
88.55
45.55
79.65
45.66
45.44
42.66
78.56
45.88
45.55
79.65
45.66
45.44
42.66
78.56
45.88
Thanks!

Best Answer

Try this
M = [
25.12
45.13
21
22
23
65.55
45.44
42.66
78.56
45.88
42.66
89.78
88.55
45.55
79.65
45.66
123.45
259.45
21.56
42.53
12.49
21
22
23
25.12
45.13
89.78
88.55
45.55
79.65
45.66
45.44
42.66
78.56
45.88
45.55
79.65
45.66
45.44
42.66
78.56
45.88];
tf = ismember(M, [21; 22; 23]);
idx = find(diff(tf)>0)+1+(0:12);
vals = reshape(M(idx).', [], 1);
Result
>> vals
vals =
21.0000
22.0000
23.0000
65.5500
45.4400
42.6600
78.5600
45.8800
42.6600
89.7800
88.5500
45.5500
79.6500
21.0000
22.0000
23.0000
25.1200
45.1300
89.7800
88.5500
45.5500
79.6500
45.6600
45.4400
42.6600
78.5600