Effacer les filtres
Effacer les filtres

Please tell me how to erase meaningless lines from graphs!

1 vue (au cours des 30 derniers jours)
장훈 정
장훈 정 le 6 Sep 2022
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')

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 6 Sep 2022
Modifié(e) : Dyuman Joshi le 6 Sep 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')

Plus de réponses (1)

Star Strider
Star Strider le 6 Sep 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.
.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by