How to find the width of plotted graph at selected Y-axis level?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dinuka Ravimal
am 19 Okt. 2020
Kommentiert: Star Strider
am 20 Okt. 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?
2 Kommentare
Rik
am 19 Okt. 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?
Akzeptierte Antwort
Star Strider
am 19 Okt. 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.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!