Pulsewidth command giving empty column vector

조회 수: 3 (최근 30일)
Shehzaib Shafique
Shehzaib Shafique 2021년 8월 21일
댓글: Star Strider 2021년 8월 22일
Hello
I am trying to find the 66% width of different pulses of a Atrial Blood Pressure signal by using following command syntax:
pulsewidth(chunk,t,'MidPercentReferenceLevel',66)
where "chunk" is pulse and "t" is time.
when i use this command, it gives me values for some pulses width and for some pulse i get "0×1 empty double column vector". for example i am getting "0×1 empty double column vector" in the attached picture of pulse. can someone tell me which thing i am doing wrong? and can someone help me how to find 66% width without having empty column vector?
i would be thankful to you

채택된 답변

Star Strider
Star Strider 2021년 8월 21일
It would be nice to see the waveforms that give values and those that do not.
I suspect the reason is that the ones that do not, have initial or final values that are not the same, as the one in the plot image shows. One possible way to deal with that is to get the minimum of the pressure waves for the entire recording and use that as the zero reference. For the waves that do not return values, it would then be necessary to find the maximum for that particular wave and calculatlate the 66% width.
One approach to that might be something similar to:
x = linspace(-5000, 5000, 250);
y = [7.5; 1.9; 0.9] .* exp(-(0.001*[1; 0.85; 0.6] * x).^2);
[ymx,idx] = max(y,[],2);
hafmax = ymx*0.66;
for k = 1:numel(hafmax)
idxrng1 = find(y(k,1:idx(k))<hafmax(k), 1, 'last');
idxrng2 = find(y(k,idx(k):numel(x))<hafmax(k),1,'first')+idx(k);
xm(k,1) = interp1(y(k,idxrng1+(-3:3)), x(idxrng1+(-3:3)), hafmax(k));
xm(k,2) = interp1(y(k,idxrng2+(-3:3)), x(idxrng2+(-3:3)), hafmax(k));
end
format short g
xm
xm = 3×2
-644.86 644.86 -758.58 758.58 -1074.5 1074.5
format short
figure
plot(x, y)
hold on
for k = 1:numel(hafmax)
plot([xm(k,1) xm(k,2)], [1 1]*hafmax(k), '-k', 'LineWidth',1.5)
end
hold off
grid
xlim([-1 1]*2000)
This was designed to reply to a different problem, however it would work here as well, since it returns the independent variable values for the dependent variable equalling a specific value, so determining the width would simply mean subtracting those values (here, the columns of ‘xm’). It will be necessary to decide, likely for every waveform that does not return values, to use either the ascending or descending parts of the waveform to calculate the 66% value.
.
  댓글 수: 8
Shehzaib Shafique
Shehzaib Shafique 2021년 8월 22일
Now it worked. Thank you so much sir for you time and help.
Star Strider
Star Strider 2021년 8월 22일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Generation에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by