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

31 views (last 30 days)
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 ?

Answers (1)

Paul on 19 Oct 2021
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);
pw = 
fplot(pw,[0 6])
Is there supposed to be a continuity constraint at the transition points?
Paul on 21 Oct 2021
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
% combine into a single signal

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!