Need help with "mirroring" function

This is my code so far:
t=0:(20000/723/.05) % (20000/723/.05) represents the value of t when theta = 0
x= .05*t
theta = acos(.0723*x / 2)
plot(t, theta)
My goal is to take the plot of the function on this t interval and mirror it across t = 20000/723/.05. Then I want to mirror this mirrored image across t = 40000/723/.05, then mirror that mirrored image across t = 60000/723/.05, and so on. Not sure if this makes sense, so my drawing below shows what I have in blue, and what I want to add in red.
Essentially, as t goes to some number (finite, but I don't know what yet) I want the plot to keep mirroring. Does anyone know how I could do this?

1 comentario

William Rose
William Rose el 2 de Abr. de 2021
This works:
>> x=0:.01:1;
>> y=log(1+x);
>> plot([x,x(end)+x,2*x(end)+x,3*x(end)+x],[y,flip(y),y,flip(y)]);
See output plot.

Iniciar sesión para comentar.

 Respuesta aceptada

William Rose
William Rose el 2 de Abr. de 2021

1 voto

Using your equations and ranges, you would do:
>> x= .05*(0:(20000/723/.05));
>> theta = acos(.0723*x / 2);
>> plot([t,t(end)+t,2*t(end)+t,3*t(end)+t],[theta,flip(theta),theta,flip(theta)])
which produces the plot below. Extend it as much as you wish.

3 comentarios

William Rose
William Rose el 3 de Abr. de 2021
My previous answer plotted x vs θ, but you wanted t versus θ. Therefore do
>> t=0:553;
>> te=t(end);
>> theta=acos(1.8075e-3*t);
>> plot([t,te+t,2*te+t,3*te+t,4*te+t],[theta,flip(theta),theta,flip(theta),theta]);
I added another segment to the plot, I got rid of x, which was not needed, and I simplified the fractions. As you can see, the hoizontal axis is now t, not x.
Rosemaryl21
Rosemaryl21 el 3 de Abr. de 2021
Editada: Rosemaryl21 el 3 de Abr. de 2021
Thank you so much for the help! This is exactly what I was looking for. I really appreciate it.
William Rose
William Rose el 4 de Abr. de 2021
You;re welcome @Rosemaryl21.

Iniciar sesión para comentar.

Más respuestas (1)

William Rose
William Rose el 2 de Abr. de 2021

0 votos

This works:
>> x=0:.01:1;
>> y=log(1+x);
>> plot([x,x(end)+x,2*x(end)+x,3*x(end)+x],[y,flip(y),y,flip(y)]);
See output plot.

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Abr. de 2021

Comentada:

el 4 de Abr. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by