How to plot circular phase in planar axis without lines going from ymin to ymax when data goes from -pi to pi?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Keith Doelling
el 25 de Sept. de 2023
Comentada: Star Strider
el 25 de Sept. de 2023
I am try to plot a phase response curve on a planar axis. This means when the response is near
it may shift directly to π because they are mathematically equivalent in this case. When I plot this on a typical axis, it can lead to a lot of big vertical lines crossing from ymin to ymax which make the appearance of a big shift in the data where none exists. I would like to get rid of this while still plotting using a line as the data is sampled highly enough that continuity should be reasonably inferred. See an image of the problem below.

Instead what I am looking for is to remove the abrupt cross graph lines that occur when values around pi and -pi cross over. Something like this figure which I've drawn over a scatter plot of the same figure.

Is there anyway to have a continuous line that stops during abrupt transitions?
Edited: Edit to add the goal plot to the main text, in answer to star strider's response!
0 comentarios
Respuesta aceptada
Star Strider
el 25 de Sept. de 2023
I am not certain what result you want. The phase plots appear to be radian measure and otherwise relatively continuous, so see if the unwrap function will do what you want.
4 comentarios
Star Strider
el 25 de Sept. de 2023
As always, my pleasure!
The alternative approach that involves plotting the segments still requires NaN entries to avoid plotting the connecting llines, although if I remember correctly, it previously didn’t require them —
x = linspace(0, 2*pi, 250);
y = rem(5*sin(x) - x/2, pi);
figure
plot(x, y)
idx = find(diff(sign(abs(y) - pi*0.955)));
idx = [1 idx numel(x)]; % This Requires 'idx' To Have An Even Number Of Elements.
idxm = reshape(idx, 2, [])
figure
hold on
for k = 1:size(idxm,2)
idxrng = idxm(1,k) : idxm(2,k);
plot([NaN x(idxrng(2:end))], [NaN y(idxrng(2:end))])
end
hold off
.
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh 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!




