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

3 views (last 30 days)
Dinuka Ravimal on 19 Oct 2020
Commented: Star Strider on 20 Oct 2020
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?

Rik on 19 Oct 2020
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 on 20 Oct 2020
Thank you

Star Strider on 19 Oct 2020
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.

Dinuka Ravimal on 20 Oct 2020
Thank you so much, through your code I got results.
Star Strider on 20 Oct 2020
As always, my pleasure!