How to fix the waterfall plot curtain along the y-axis bug?

17 views (last 30 days)
I'm plotting US-echo signals in a waterfall plot. Basically, the dataset is as follow:
  • x-axis: frame of US echo-signal
  • y-axis: different frames of US echo-signal, which in practical terms is the running time of the experiment
  • z-axis: amplitude of the US echo-signal
The plotting code works for all the datasets, however, sometimes I get a bug in a specific frame. Instead of applying the curtain on the area below the graph along the y-axis, it applies a partial curtain above the graph. It is not constant, as you see in the picture, there are areas in that frame where the curtain is correctly applied and others where it does not.
The bug appears in the same frame of the dataset (same t (s) of running time os experiment) everytime I run the code, no matter if I plot different ranges of the dataset. This means, I can plot the whole dataset (n=5000), or just 10 frames where the bug is appearing and the resulting bug is the same. However, at each dataset (different experiments, and, therefore, different echo-signals), the bug is appearing in different frames. Until now it has only appeared once at the most on each dataset.
I'm also plotting the peaks of each echo, but this has no affect on the bug, as I also tried without plotting the peaks (red dots) and the bug still happens on the same site.
I don't think the error is in the data, as I have gone over it, but I cannot find a reason for the curtain to fail in a specific frame while for the others it seems to work fine.
Thank you very much for your attention.
Here is the code:
Tinterval=2e-9;
tstamp1_1=1e-05;
tstamp2_1=2.6e-05;
PRF=2000;
samples=round((tstamp2_1-tstamp1_1)./Tinterval)+1;
startFrame=1370;
endFrame=1385;
numfiles = endFrame-startFrame;
c=zeros(samples,numfiles);
v1=zeros(1,numfiles);
v2=zeros(1,numfiles);
i=1;
for k = startFrame:endFrame-1
c(:,i)=echoFilter(k,:);
v1(1,i)=echoFilter(k, Peaks(k,1));
v2(1,i)=echoFilter(k, Peaks(k,2));
i=i+1;
end
figure(1)
T_echo=[tstamp1_1:Tinterval:tstamp2_1];
x=T_echo;
y=[startFrame:endFrame-1]./PRF;
[X,Y]=meshgrid(x,y);
z=c;
zinv=transpose(z);
w=waterfall(X,Y,zinv);
xlim([T_echo(1) T_echo(end)]);
ylim([startFrame endFrame-1]./PRF);
xlabel('Echo time (s)');
ylabel('Running time (s)');
zlabel('Voltage(V)');
hold on
plot3(T_echo(Peaks(startFrame:endFrame-1,1)), y, v1, 'r.', T_echo(Peaks(startFrame:endFrame-1,2)), y, v2, 'r.')
  3 Comments
Ana Seabra
Ana Seabra on 26 May 2021
"echoFilter" is a matrix with the echo voltage data for each frame:
  • row: frame
  • column: echo sample
So echoFilter(1375,1000) returns the voltage value of sample 1000 (corresponding to echo time 1.1998e-05 s) in frame 1375 (corresponding to running time 0.6875 s).
Attatched is a part of the plotted data matrix. Frame 26 is the one at fault, where the curtain is in the upper part of the graph instead of below.
Thank you in advance.

Sign in to comment.

Answers (1)

Cris LaPierre
Cris LaPierre on 10 Jun 2021
There appears to be an issue when plotting using very small step sizes in X. If you create the waterfall plot without specifying X or Y, it seems to work. If you multipy X by as little as 1.6, it also appears to work as expected. Even odder, if you circshift echoFilter2 it all appears to work as expected. This suggests it is some combination of X,Y, and Z that is causing the problem.
The workaround for now may be to increase your X values, and then modify the x axis tick labels to be what they should be. The code for that might be the following
% multiply x by 10 to avoid issues with small values
x=[tstamp1_1:Tinterval:tstamp2_1]*10;
y=[1:51]./PRF;
[X,Y]=meshgrid(x,y);
% waterfall(X(25:27,:),Y(25:27,:),echoFilter2(25:27,:))
waterfall(X,Y,echoFilter2)
xlabel('Echo time (s)');
ylabel('Running time (s)');
zlabel('Voltage(V)');
% Adjust x tick labels to display actual x values
h=gca;
h.XAxis.Exponent = 0;
xt = str2double(xticklabels);
xticklabels(xt/10);
h.XAxis.Exponent = -5;

Categories

Find more on Polar Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!