I have to create a rectangular signal with a different period and amplitude at every run, but I don t know how to chnage the aplitude

조회 수: 4 (최근 30일)
clc
close all
clear all
format long
Fs1=1000;
Fs2=1000;
Ts1=1/Fs1;
Ts2=1/Fs2;
A1=1;
A2=2;
t1 =-2 : Ts1 : 2;
t2=-2 : Ts2 :2;
x1=rectpuls(t1,rand);
x2=rectpuls(t2,rand);
figure
plot(t1,x1,t2,x2)
grid

채택된 답변

Askic V
Askic V 2022년 12월 9일
편집: Askic V 2022년 12월 9일
Just play with randn (normal/gauss distrbution):
clc
close all
clear all
format long
Fs1=1000;
Fs2=1000;
Ts1=1/Fs1;
Ts2=1/Fs2;
A1=1;
A2=2;
t1 =-2 : Ts1 : 2;
t2=-2 : Ts2 :2;
width1 = 1+0.5*randn; % Signal width is 1 with std deviation +-0.5
width2 = 1+2*randn; % Signal width is 1 with std deviation +-0.5
amp1 = 3 + 2*randn; % amp1 is 3 with deviation of +-2
amp2 = 2 + 0.5*randn;
x1 = amp1*rectpuls(t1,width1);
x2 = amp2*rectpuls(t2,width2);
figure
plot(t1,x1,t2,x2)
grid

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by