Plotting function over multiple periods
11 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Sam McDonald
on 6 Mar 2017
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 Comments
More Answers (0)
See Also
Categories
Find more on Assumptions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!