Borrar filtros
Borrar filtros

how should i fix my graph to not display the line going back to center.

7 visualizaciones (últimos 30 días)
using my code below i'm trying to plot the z lines into the complex plane, and then plot only the |R| values less than 1.
to be clear i'm creating "lines" of z for my initial values where some of the real/imaginary values are already given.
for instance point z = .2, i'm making it into a line by giving it multiple values in the imaginary. (maybe this is a complicated way of doing it, idk)
(ignore the line spacing in the z inputs, i just moved them down to be more visible here, they are one solid line in my code)
z = [0.2+(-500:.05:500)*1i 0.5+(-500:.05:500)*1i 1+(-500:.05:500)*1i 2+(-500:.05:500)*1i
4+(-500:.05:500)*1i 10+(-500:.05:500)*1i (-500:.05:500)-10i (-500:.05:500)-4i (-500:.05:500)-2i
(-500:.05:500)-1i (-500:.05:500)-0.5i (-500:.05:500)-0.2i (-500:.05:500)+0.2i (-500:.05:500)+0.5i
(-500:.05:500)+1i (-500:.05:500)+2i (-500:.05:500)+4i (-500:.05:500)+10i 0+(-500:.05:500)*1i ];
R = (z-1)./(z+1);
x = abs(R);
idx=x<=1;
plot(real(R(idx)),imag(R(idx)));
title('R Plane Chart');
however my plot links the ends of my graph back to the origin like this:
I need the plot NOT to graph the line from the end of the curves back to the center.
can someone explain why is it doing this, and how to fix it?
thank you so much!

Respuesta aceptada

Walter Roberson
Walter Roberson el 13 de Jul. de 2021
format long g
z = [0.2+(-500:.05:500)*1i nan 0.5+(-500:.05:500)*1i nan 1+(-500:.05:500)*1i nan 2+(-500:.05:500)*1i nan ...
4+(-500:.05:500)*1i nan 10+(-500:.05:500)*1i nan (-500:.05:500)-10i nan (-500:.05:500)-4i nan (-500:.05:500)-2i nan ...
(-500:.05:500)-1i nan (-500:.05:500)-0.5i nan (-500:.05:500)-0.2i nan (-500:.05:500)+0.2i nan (-500:.05:500)+0.5i nan ...
(-500:.05:500)+1i nan (-500:.05:500)+2i nan (-500:.05:500)+4i nan (-500:.05:500)+10i nan 0+(-500:.05:500)*1i ];
R = (z-1)./(z+1);
x = abs(R);
idx = isnan(x) | x<=1;
plot(real(R(idx)),imag(R(idx)));
title('R Plane Chart');
  3 comentarios
Walter Roberson
Walter Roberson el 13 de Jul. de 2021
You are using the colon operator, so nan is not after every z value, but rather after each series of z values, separating that parts.
You are using idx as a logical selection, only plotting the parts that meet the match. So I extended the match to include the isnan() locations. The result is that for any given sub-series, the ones matching abs(x)<=1 will be selected, and as well the nan separating the series will be selected. R(idx) will contain a mix of data with nan separating the subsets.
Keeping the nan as part of what is plotted is important because MATLAB only plots places that have adjacent finite values. Encountering the "nan" effectively means "Pen Up (stop drawing)". So you draw one of the subsequences, then you stop drawing and move to the beginning of the next sub-sequence, instead of drawing back to the beginning. For example if your data were 1 2 3 4 1 2 3 4 continuous, then you would get a single line that went 1 to 2 to 3 to 4 back to 1 then 2 then 3 then 4, with there being a line joining the 4 to the 1. But if you had 1 2 3 4 nan 1 2 3 4 then after the 1 2 3 4 part, it would lift up the pen and not draw a connection between the 4 and the 1.
david Price
david Price el 13 de Jul. de 2021
Ok, i think i understand now.
I need the nan in with the z values to be used later as stop points in the plot.
so then the plot sees the isnan(x) values as stop points in between plotting the other series of z-values.
Thanks this was really informative compared to me using the documentation help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by