Plotting function over multiple periods

조회 수: 11 (최근 30일)
Jente Marien
Jente Marien 2017년 3월 4일
답변: Sam McDonald 2017년 3월 6일
syms x
fplot(2* triangularPulse((5*x)/7) - 5*rectangularPulse((3*x)/2), [-4,4])
this is my function at the moment but I have to plot this over 4 periods. I have no idea how i can solve this.

채택된 답변

Sam McDonald
Sam McDonald 2017년 3월 6일
Since the "fplot" function accepts a symbol expression, you can simply add more symbolic data to it before calling the function. Here is a trivial example of this technique:
syms x
y = x;
g = (x-2);
fplot(y+g)
Notice how I added two symbolic functions together and plotted the resulting expression. You can construct multiple expressions and add them together to plot multiple pulses over several periods. Here is an example that is similar to what you are trying to accomplish:
syms x
T = 6; % Period
N = 2; % number of pulses
shiftedF = @(x, t) triangularPulse((x-t)/3) + rectangularPulse((x-t)/2);
y = shiftedF(x,0);
for i = 1:N
y = y + shiftedF(x, i*T);
end
fplot(y, [-T/2 T/2+N*T])
You will need to adjust the code to get exactly what you are looking to do, but the missing piece was knowing that you could add multiple expressions and them plot them just the same.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by