Plotting function over multiple periods

3 次查看(过去 30 天)
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 中查找有关 Calculus 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by