How to find the width of plotted graph at selected Y-axis level?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
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?
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!