Plotting function over multiple periods
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jente Marien
am 4 Mär. 2017
Beantwortet: Sam McDonald
am 6 Mär. 2017
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 Kommentare
Akzeptierte Antwort
Sam McDonald
am 6 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Assumptions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!