How to find a pattern in an array?

47 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
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!