Borrar filtros
Borrar filtros

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

5 visualizaciones (últimos 30 días)
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 ?

Respuestas (1)

Paul
Paul el 19 de Oct. de 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);
end
pw
pw = 
fplot(pw,[0 6])
Is there supposed to be a continuity constraint at the transition points?
  2 comentarios
Omkar Vaze
Omkar Vaze el 21 de Oct. de 2021
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 el 21 de Oct. de 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
plot(t,s)
% combine into a single signal
plot(t(:),s(:))

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by