How to give different colors to different regions of a signal(extracted from an audio amplitude-Fs)?
1 view (last 30 days)
Show older comments
i need to give different colors with an interval of 1 second
0 Comments
Answers (1)
Mathieu NOE
on 23 Nov 2021
hello
maybe this ?
clc
clearvars
% signal
Fs = 100;
dt= 1 /Fs;
samples = 5*Fs; % 5 seconds of signal
freq = 3;
t = (0:samples-1)*dt;
x = sin(2*pi*freq*t);
buffer_seconds = 1; % buffer length in seconds
buffer = buffer_seconds*Fs; % buffer length in samples
figure(1),hold on
for ci = 1:fix(samples/buffer)
start_index = 1+(ci-1)*buffer;
stop_index = min(start_index+ buffer,samples);
tt = t(start_index:stop_index); %
xx = x(start_index:stop_index); %
plot(tt,xx)
end
hold off
0 Comments
See Also
Categories
Find more on Signal Processing Toolbox 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!