How to create animations with scatterplot and scatter?
9 次查看(过去 30 天)
显示 更早的评论
I import a .wav file with audioread function. It's a real signal that then I convert to analytical one since I need to plot the constellation diagram (I-Q plane) and phase; in particular I need to show how IQ samples and phase evolves in time: I want to show the current diagram with time step of 1 second and display the time inside the plots.
Here is a MWE:
clc; clear all; close all;
sig = rand(100,1); %signal channel signal
num_sampl = numel(sig) %number of samples
sig_complex = hilbert(sig); % get the analytic signal
duration = 10 %seconds
F_s = num_sampl/duration; %sampling frequency 5 samples = 1 sec -> F_s = 3Hz)
time_vec = 1:1:duration;
% Movie of IQ samples
figure;
for i = 1:length(time_vec)
xlim([-1,1]); ylim([-1,1]);
sam_start = (i - 1) * F_s + 1;
sam_end = i * F_s;
samples_current = sam_start:1:sam_end;
scatterplot(sig_complex(samples_current)); hold on
%pause(1);
str = "t = "+ num2str(time_vec(i)) + "s";
subtitle(str);
drawnow;
end
% Movie of phase
figure;
for i = 1:length(time_vec)
xlim([-1,1]); ylim([-1,1]);
sam_start = (i - 1) * F_s + 1;
sam_end = i * F_s;
samples_current = sam_start:1:sam_end;
phase = angle(sig_complex(samples_current));
scatter(time_vec(samples_current),phase); hold on
pause(1);
str = "t = "+ num2str(time_vec(i)) + "s";
subtitle(str);
drawnow;
end
0 个评论
回答(1 个)
Walter Roberson
2023-11-4
time_vec = 1:1:duration;
That is not correct. It should be
time_vec = (0:num_samp-1)/Fs;
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!