Pulsewidth command giving empty column vector
2 views (last 30 days)
Show older comments
Shehzaib Shafique
on 21 Aug 2021
Commented: Star Strider
on 22 Aug 2021
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

0 Comments
Accepted Answer
Star Strider
on 21 Aug 2021
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
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


