简体   繁体   中英

How to insert a known frequency in a sinusoid with different frequencies at specified time chunk using MATLAB

I have a sinusoidal signal of 2000 msec length and varying frequency levels. I want to insert a known frequency of 10Hz at a known time chunk (600-800 msec for example). while keeping the rest of signal same. Any idea how can i do this using MATLAB? Here's how i generated the signal

%range of possibles frequencies
FrequenciesRandon = [8:0.5:13];
%number of randon frequencies ??
nf = 10;
delta=0.005; 
samples=200;
t=0:delta:delta*(samples-1);
ch2=[];

for j = 1 : nf

  f=randsample(FrequenciesRandon,1); % get the randon frequencie                         % Sampling Frequency
  signal = sin(2*pi*f*t)';        % Generate Sine Wave  
  ch2= [signal;ch2];    
end

You can add below code to yours to perform the example you proposed and plot it to check:

fInsert = 10;
signalInsert = sin(2*pi*fInsert*t);
timeStart = 600;
timeFinish = 799;
ch2(timeStart:timeFinish) = signalInsert;
plot(ch2)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM