I am trying to reflect the graph closest to the origin. The reflection should start where the graph ends. I have not achieved this. Please see figure1. Any ideas? much appreciated
for n = 1:5;
v = v(n);
i;
d=z1/cosd(i); %calculate diagonal distance
h(n)=z1*sind(i); %calculate horizontal distance
t(n) = d/v;
v = [3:7];
depth(n)=z1
sini = ((sind(i)*(v+1))/v);
i= asind(sini)
z1=z1+2;
end
N=cumsum(h);
plot(h,depth)
hold on
grid on
B=cumsum(h)+N(:,end)
C=flip(depth)
plot(B,C)
axis ij

3 comentarios

Image Analyst
Image Analyst el 11 de Mzo. de 2015
I don't know what reflect means to you. Like a mirror image about some line? If so, which line, or axis? Please attach a picture of what you'd like to get out.
JDilla
JDilla el 11 de Mzo. de 2015
Sort of like that. Although they should be touching. I just did that on paint
JDilla
JDilla el 11 de Mzo. de 2015
Does that help show what I mean?

Iniciar sesión para comentar.

 Respuesta aceptada

Michael Haderlein
Michael Haderlein el 11 de Mzo. de 2015

0 votos

I guess you want something like this:
>> x=1:10;y=x.^2.*rand(size(x));
>> figure, plot(x,y), hold all
>> reflectionx=8;
>> plot(2*reflectionx-x,y)

3 comentarios

JDilla
JDilla el 11 de Mzo. de 2015
Editada: JDilla el 11 de Mzo. de 2015
Sort of? I need it to be the same colour, and how would I implement that technique into my own code? I need the reflection to occur at the end of where the first graph ends, it seems you have got it to reflect at x=8? I have tried using (:,end) but I'm not sure
Michael Haderlein
Michael Haderlein el 11 de Mzo. de 2015
same color -> use "hold on" instead of "hold all" or set the color explicitly (see the plot documentation)
reflection point -> "reflectionx=x(end);" in case that x is monotonically increasing or "reflectionx=max(x);" in case that the order of x is arbitrary.
implement into your own code -> I don't fully understand your code but I see you have two plots. Also I don't know which of them you want to reflect, but in both cases you have x-values and y-values ((h,depth) resp. (B,C)). In case you want to reflect the first one, use my code and replace x with h and y with depth. Same procedure with the second plot, respectively.
JDilla
JDilla el 11 de Mzo. de 2015
Editada: JDilla el 11 de Mzo. de 2015
Finally got it, thank you very much for your help!

Iniciar sesión para comentar.

Más respuestas (1)

Deeptanu Datta
Deeptanu Datta el 18 de Dic. de 2019

0 votos

How to take mirror image of a plot about the straight line y=-x ?

Categorías

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

Etiquetas

Preguntada:

el 11 de Mzo. de 2015

Respondida:

el 18 de Dic. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by