How to give different colors to different regions of a signal(extracted from an audio amplitude-Fs)?

1 次查看(过去 30 天)
i need to give different colors with an interval of 1 second

回答(1 个)

Mathieu NOE
Mathieu NOE 2021-11-23
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

类别

Help CenterFile Exchange 中查找有关 Signal Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by