I am trying to find the full width at half max value and plot the waveform with markers

5 ビュー (過去 30 日間)
I have a voltage waveforn captured using an osciloscope and saved in a csv file. I am trying to find the full width at half max value and plot the waveform with markers. Column 4 is the time (x axis) and column 5 is the voltage data (y axis) in the csv file. Can someone please help me?
Thanks

採用された回答

Star Strider
Star Strider 2021 年 8 月 27 日
Explore the options of the Signal Processing Toolboox pulsewidth function.
.
  6 件のコメント
BP
BP 2021 年 9 月 1 日
This has been a great help. I am new to MATLAB. Please explane what the following steps / commands in the code does. A line by line explanation would really help me.
[ymx,idx] = findpeaks(y, 'MinPeakProminence',100)
ymx = 923.1334
idx = 1028
hafmax = ymx*0.5;
for k = 1:numel(hafmax)
idxrng1 = find(y(1:idx(k))<hafmax(k), 1, 'last');
idxrng2 = find(y(idx(k):numel(x))<hafmax(k),1,'first')+idx(k);
xm(k,1) = interp1(y(idxrng1+(-3:3)), x(idxrng1+(-3:3)), hafmax(k));
xm(k,2) = interp1(y(idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k));
Star Strider
Star Strider 2021 年 9 月 1 日
Sure!
The first is just a findpeaks call. I refer you to that documentationo to understand what it does. It returns the maximum peak and the associated index into that vector for reference later.
The ‘hafmax’ variable is just that — it is the value at half the maximum (although it can be value defined on the dependent variable range, depending on what you want to do).
The loop is a bit mor complicated. To use the interp1 function correctly, the independent variable (first argument to the function) has to be monotonically increasing or decreasing. Since the objective is to find the values for both the ascending and descending limbs of the curve, the code requires a separate interp1 call for each limb as the result. That explains the two ‘idxrng’ calls, one for each section of the curve, and a separate interp1 call for each section of the curve, producing two values of ‘xm’ correspondingly. The easiest way to understand how it works is to add a plot statement to the loop to display the different sections being interpolated.
.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Estimation についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by