Borrar filtros
Borrar filtros

Please tell me how to erase meaningless lines from graphs!

2 visualizaciones (últimos 30 días)
In the graph above, I want to erase the line that crosses pi at -pi, how can I do it?
I wasn't there originally... It's a simple question, but I can't solve it.
plot(data(:,1),data(:,2))
xlim([-pi pi])
xticks(-pi:pi/2:pi)
xticklabels({'-\pi','-\pi/2','0','\pi/2','\pi'})
pbaspect([ 1 1 1])
grid on
xlabel('rad')
ylabel('mm')

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 6 de Sept. de 2022
Editada: Dyuman Joshi el 6 de Sept. de 2022
There is repetition in your data, 1st and Last row are the same.
%plot upto 2nd last row
plot(data(1:end-1,1),data(1:end-1,2))
xlim([-pi pi])
xticks(-pi:pi/2:pi)
xticklabels({'-\pi','-\pi/2','0','\pi/2','\pi'})
pbaspect([ 1 1 1])
grid on
xlabel('rad')
ylabel('mm')

Más respuestas (1)

Star Strider
Star Strider el 6 de Sept. de 2022
There is no need to discard any data. Just use sortrows to sort them —
LD = load(websave('data','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1117765/data.mat'));
data = LD.u;
data = sortrows(data,1);
plot(data(:,1),data(:,2))
xlim([-pi pi])
xticks(-pi:pi/2:pi)
xticklabels({'-\pi','-\pi/2','0','\pi/2','\pi'})
pbaspect([ 1 1 1])
grid on
xlabel('rad')
ylabel('mm')
The ‘wrapped’ lines are almost always solved by sorting.
.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by