How to find a pattern in an array?

11 views (last 30 days)
Susan
Susan on 12 Aug 2022
Commented: Susan on 27 Aug 2022
Hi All,
I have an array (attached) and I'd like to find where a specific pattern happens in the array.
I know that by knowing the pattern we can find how many times and where in the array this pattern happens using the following code (How to find pattern in an array? - (mathworks.com))
clear all
clc
data = importdata('C:\User\Downloads\test\TEST.txt');
A = '118'; % Pattern
B = convertStringsToChars(data{1,1});
SIZE = length(B) - length(A);
match = zeros(1, SIZE);
for i=1:SIZE
match(i) = all(B(i:i-1+length(A)) == A);
end
output = find(match == 1);
size(output)
However, my question is if I know a pattern happens X times, say 100 times, in the array while I don't know what the pattern is, Is it possible to find the pattern?
Many thanks in advance!
  51 Comments
dpb
dpb on 26 Aug 2022
If our presumptions were correct, the orientation in the file should be sequentially in time for each channel -- so if you have a channel disconnected, its constant signal should show up as every 1:8:N values if our assumption that the channels are multiplexed is correct. This appears must be so given the flat line in your plot, but would be good to visually inspect the layout directly to be sure.
A 300 mV DC signal at G=10 counts/mV would output 3000 counts.
That then I presume is with an open input channel? What if you ground the unconnected channel(s)?
Susan
Susan on 27 Aug 2022
@dpb Thanks for your quick response. Appreciate it. When I knew that only one channel was recorded and the rest were open input channels, I got a t*8 matrix that only one channel had data, and all the rest values/matrix entries were fixed to 3000.
You're right; it is with an open input channel. I haven't grounded the unconnected channels yet, but I will.
Then, if I assume every ten units (or whatever) equals 1mV, then how to interpret the 2*10^3mV of ECG's amplitude?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!