How to generate continuous time domain signal with different start and end time?
조회 수: 7 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
fplot(pw,[0 6])
Is there supposed to be a continuity constraint at the transition points?
댓글 수: 2
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 Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!