필터 지우기
필터 지우기

How to detect the specific area from an oscilloscope signal

조회 수: 1 (최근 30일)
Duc Khanh
Duc Khanh 2024년 6월 5일
댓글: Star Strider 2024년 6월 11일
Hello,
I don't have any experience with MATLAB or coding, therefore I ask you about the general idea and method so that I can solve that easier.
I have two types of patterns, as shown in the attachment, the first type has the unique signal before coming back to the noise level for 0.15-0.2s. While the second one has typically longer time,
Each type has about hundreds files of similar pattern. So how can I create a a program to detect if it is type 1 or type 2 when inserting a random file (.csv format) in 2 groups?
  댓글 수: 2
Mathieu NOE
Mathieu NOE 2024년 6월 5일
편집: Mathieu NOE 2024년 6월 5일
hello
you have some data available ?
does the spike always occurs in type 1 or is the quiet zone duration the only way to differenciate the two types ?
Duc Khanh
Duc Khanh 2024년 6월 5일
Hi,
I have around 5 files for each, I attached one for each type. I think only type 1 has a very high peak while type 2 does not. Beside the quiet zone duration, I think the signal peak is another way but my boss prefer the quiet zone stuff.
Thanks in advance.

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2024년 6월 5일
편집: Star Strider 2024년 6월 5일
Perhaps something like this —
jpgs = dir('*.jpg');
csvs = dir('*.csv');
for k = 1:numel(jpgs)
figure
imshow(imread(jpgs(k).name))
end
for k = 1:numel(csvs)
T{k,:} = readtable(csvs(k).name);
Trm = rmmissing(T{k});
[eu,ed] = envelope(Trm{:,2}, 2, 'peak');
Lv = ed >= -0.2;
[ts,te] = bounds(Trm{Lv,1});
tdur = te-ts;
thrshld = 0.2;
Type = 1;
if tdur > thrshld
Type = 2;
end
figure
plot(Trm{:,1}, Trm{:,2}, 'DisplayName','Signal')
hold on
plot(Trm{:,1}, ed, '-r', 'DisplayName','Lower Envelope')
plot(Trm{:,1}, Lv*0.5, '-k', 'DisplayName','Decision Logical Vector')
hold off
grid
ylim([-1 1])
xlabel('Time (s)')
ylabel('Voltage (V)')
if Type == 2
ylabel('B')
end
title(["Type = "+Type+", Gap Duration = "+tdur+" s", "Filename: "+csvs(k).name])
legend('Location','best')
end
You can remove many (if not all) of the plot calls. I kept them in to demonstrate how the code works.
EDIT — Added the file name to the title text.
.
  댓글 수: 10
Duc Khanh
Duc Khanh 2024년 6월 11일
편집: Duc Khanh 2024년 6월 11일
Thank you Mr. Star Strider, I managed to modify your code for specific files, it was quite hard at first because I know nothing about coding but your explanation helps me a lot.
From what I learnt, for example, if I want to detect anything lower than 0.5, I will write lvl = -0.5. And tv is the distance from that signal starts until it return back to the normal noise, isnt it?
Star Strider
Star Strider 2024년 6월 11일
As always, my pleasure!
Thank you!
I will always help to change my code if you want to change it. Please just ask.
The ‘lvl’ value is the level where the lower signal envelope (the red line in my code) first crosses that value until it again crosses it on the other side of the gap. So it has to be some value greater than the lowest value of the envelope. (I arbitrarily chose -0.2 because it worked for alll the files.)
You can get the minimum value of the envelope with:
ed_min = min(ed(1:20));
calculating the miniumum of the first 20 values of the envelope, for example. You might need to do the same thing on the other end as well, if the envelope amplitudes are not the the same before and after the gap (as with tek0094.csv):
ed_min(1) = min(ed(1:20));
ed_min(2) = min(ed(end-19:end));
That will return a vector of the two values. Then choose ‘lvl’ to be the value you want. In that instance, it has to be greater than the highest value of ‘ed_min’, that being ‘ed_min(2)’ or equivalently ‘max(ed_min)’.
Change the index vectors as necessary to produce the result you want.
And tv is the distance from that signal starts until it return back to the normal noise, isnt it?
The ‘tv’ vector are all the values where the lower envelope ‘ed’ crosses the ‘lvl’ value. The ‘tdur’ value is the time between the minimum (or maximum) values of ‘tv’ (depending on how you want to define it) if there are more than two crossings, as with the tek0166.csv file. If there are only two crossings, ‘tdur’ is simply the time difference between them.
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by