How to generate continuous time domain signal with different start and end time?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 ?
0 Kommentare
Antworten (1)
Paul
am 19 Okt. 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
fplot(pw,[0 6])
Is there supposed to be a continuity constraint at the transition points?
2 Kommentare
Paul
am 21 Okt. 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(:))
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!