Borrar filtros
Borrar filtros

Plotting function over multiple periods

3 visualizaciones (últimos 30 días)
Jente Marien
Jente Marien el 4 de Mzo. de 2017
Respondida: Sam McDonald el 6 de Mzo. de 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.

Respuesta aceptada

Sam McDonald
Sam McDonald el 6 de Mzo. de 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.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by