필터 지우기
필터 지우기

generating/plotting aperiodic functions

조회 수: 2 (최근 30일)
Sarah
Sarah 2011년 11월 10일
Hey guyssss,
Can someone explain to me how I can define an aperiodic square function in MATLAB? This is the code I have for time:
TimeStep = 0.0001*2*pi; %time increment
Time.Start = 0; %time interval starting time
Time.End = 10*2*pi; %time interval ending time
Time = Time.Start:TimeStep:Time.End;
I want to be able to change the width and amplitude of the function. Any help would be greatly appreciated :)

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2011년 11월 11일
f below will be your function.
f=@(t,StartTime,EndTime,Amplitude) Amplitude*and(StartTime<t,t<EndTime);
To test it out:
t=-1:0.1:5;
y=f(t,0.3,3.6,1.3);
plot(t,y);grid on;
  댓글 수: 6
Sarah
Sarah 2011년 11월 11일
It can be anywhere within the duration of the sinusoidal signal. I can change those parameters later, i just want the square to occur within the time duration of the signal.
Fangjun Jiang
Fangjun Jiang 2011년 11월 11일
In the f() defined in my code, the StartTime and EndTime refer to the start/end time of the square. You can put the start/end time of your signal in the time vector.
t=(0:0.0001:10)*2*pi;
y=f(t,30,50,1.3);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by