How to remove spurious lines?

7 views (last 30 days)
tandemuse
tandemuse on 15 Apr 2021
Commented: Star Strider on 17 Apr 2021
Hello everyone! Why do these horizontal lines appear in the last plot and how can I remove them?
fs = 100;
data = load("data.txt");
distance = 0.4;
time = data(:,1);
amplitude = data(:,2);
fstep = 2 : 1 : -1+0.5*fs;
N = numel(fstep)-1;
central_freqs = NaN([1 N]);
filtered = NaN([numel(time) N]);
for i = 1:N
filtered(:,i) = bandpass(amplitude,[fstep(i) fstep(i+1)],fs);
filtered(:,i) = filtered(:,i)/max(abs(filtered(:,i)));
central_freqs(i) = 0.5*(fstep(i) + fstep(i+1));
end
[Freqs,Time] = meshgrid(central_freqs,time);
surf(Freqs,Time,filtered);
shading interp
view([0 90])
ylim([-1 0])
xlim([min(central_freqs) 15])
cb = colorbar;
ylabel(cb,'Amplitude')
xlabel("Frequency (Hz)")
ylabel("time (s)")
title("Initial image")
plot3(Freqs,Time,filtered)
velocity = distance./(Time - 0.25./Freqs);
surf(Freqs,velocity,filtered);
shading interp
ylim([-2 0])
xlim([min(central_freqs) 15])
view([0 90])
cb = colorbar;
ylabel(cb,'Amplitude')
xlabel("Frequency (Hz)")
ylabel("phase velocity (km/s)")
title("Transformed image")
plot3(Freqs,velocity,filtered)
ylim([-2 0])
xlim([2.5 15])

Accepted Answer

Star Strider
Star Strider on 15 Apr 2021
Sort ‘velocity’:
[velocity, idx] = sort(velocity);
figure
plot3(Freqs,velocity,filtered(idx))
ylim([-2 0])
xlim([2.5 15])
grid on
producing:
.
  8 Comments
tandemuse
tandemuse on 17 Apr 2021
Hey Star, just wanted to let you know that I've revised the calculations and the two cases are now essentially the same. Your solution is absolutely correct. Thank you very much!
Star Strider
Star Strider on 17 Apr 2021
As always, my pleasure!
I very much appreciate your compliment, and for following up on this!

Sign in to comment.

More Answers (0)

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!