How to find the width of plotted graph at selected Y-axis level?

1 回表示 (過去 30 日間)
Dinuka Ravimal
Dinuka Ravimal 2020 年 10 月 19 日
コメント済み: Star Strider 2020 年 10 月 20 日
I want to measure the width of each signal at the y-axis's 20(TE reflection efficiency). Could you please help me with that code?
  2 件のコメント
Rik
Rik 2020 年 10 月 19 日
Your curves look like they have a relatively poor sampling. I would suggest using one of the interpolation functions. What did you try yourself?
Dinuka Ravimal
Dinuka Ravimal 2020 年 10 月 20 日
Thank you

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

採用された回答

Star Strider
Star Strider 2020 年 10 月 19 日
Try this:
lambda = linspace(0.4, 0.6); % Wavelength Vector
s = sinc(((0.47:0.02:0.55).' - lambda)*1E+2)*30; % Signal Matrix (Row Vectors)
for k = 1:size(s,1)
[maxv,idx] = max(s(k,:)); % Index Of Peak
idxv1 = idx+[-2 0];
lmda(k,1) = interp1(s(k,idxv1), lambda(idxv1), 21, 'pchip'); % Interpolate Rising Edge
idxv2 = idx+[0 2];
lmda(k,2) = interp1(s(k,idxv2), lambda(idxv2), 21, 'pchip'); % Interpolate Falling Edge
wdth(k) = lmda(k,2) - lmda(k,1); % Calculate Width
end
figure
hold on
for k = 1:size(s,1)
hp = plot(lambda, s(k,:));
plot(lmda(k,:), [1 1]*21, '+', 'Color',hp.Color) % Plot ‘+’ In Same Color As Signal
end
hold off
grid
Make appropriate changes to get my code to work with your signals. It may require some ‘tweaking’, however it should produce reasonable results.
  2 件のコメント
Dinuka Ravimal
Dinuka Ravimal 2020 年 10 月 20 日
Thank you so much, through your code I got results.
Star Strider
Star Strider 2020 年 10 月 20 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by