How to generate continuous time domain signal with different start and end time?

조회 수: 7 (최근 30일)
Omkar Vaze
Omkar Vaze 2021년 10월 19일
댓글: Paul 2021년 10월 21일
I am trying to generate 8 signals with 8 different frequencies. Each signal have same total time period. And each signal start at different time. Second signal starts at end of the first signal and so on. I want to do it in loop so that I don’t have to write repetitive instructions for all 8 signals. So how can I do it ?

답변 (1개)

Paul
Paul 2021년 10월 19일
By "continuous time domain signal" do you mean signal defined symbolically (otherwise, I'm not sure what's meant by "continuous"). If so, then
w = sym([1 2 3]); % example with three frequencies
syms t
totaltime = 2; % for example
pw = piecewise(0 < t <= totaltime, sin(w(1)*t));
for ii = 2:numel(w)
pw = piecewise((ii-1)*totaltime < t <= ii*totaltime, sin(w(ii)*t),pw);
end
pw
pw = 
fplot(pw,[0 6])
Is there supposed to be a continuity constraint at the transition points?
  댓글 수: 2
Omkar Vaze
Omkar Vaze 2021년 10월 21일
fs=f_t*20; %Sampling frequency
Ts=1/fs; %Sample time
I have frist signal with time and frequency as below:
T=0:Ts:(0.667e-3)-Ts; %Time period of signal starting at zero and end at (0.667e-3).
x1=cos(2*pi*f_actual1(3,1)*T); %signal with frequency 1
Now, the second signal have time period (0.667e-3) but start time is at (0.667e-3) and end time is (1.333334e-3).
Similarly I have 8 more signals. So how I can do this without retyping the instructions?
Paul
Paul 2021년 10월 21일
Using some made up data because not all was supplied. One way to do this:
f_actual = (1:8)*50; % frequencies
nsignals = numel(f_actual);
duration = 2/3*1e-3;
samplespersignal = 100;
Ts = duration/samplespersignal;
npts = samplespersignal*nsignals;
t = (0:(npts-1))*Ts;
t = reshape(t,samplespersignal,[]);
s = cos(2*pi*f_actual.*t);
% plot each signal individually
plot(t,s)
% combine into a single signal
plot(t(:),s(:))

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by