MATLAB Answers

How to remove spurious lines?

39 views (last 30 days)
tandemuse
tandemuse on 15 Apr 2021 at 18:40
Commented: Star Strider on 17 Apr 2021 at 19:45
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 at 20:14
Sort ‘velocity’:
[velocity, idx] = sort(velocity);
figure
plot3(Freqs,velocity,filtered(idx))
ylim([-2 0])
xlim([2.5 15])
grid on
producing:
.
  8 Comments
Star Strider
Star Strider on 17 Apr 2021 at 19:45
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!