How to detect the specific area from an oscilloscope signal
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Duc Khanh
le 5 Juin 2024
Commenté : Star Strider
le 11 Juin 2024
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 commentaires
Mathieu NOE
le 5 Juin 2024
Modifié(e) : Mathieu NOE
le 5 Juin 2024
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 ?
Réponse acceptée
Star Strider
le 5 Juin 2024
Modifié(e) : Star Strider
le 5 Juin 2024
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 commentaires
Star Strider
le 11 Juin 2024
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.
.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Multirate Signal Processing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!











