Effacer les filtres
Effacer les filtres

Indices shown in plot are off

17 vues (au cours des 30 derniers jours)
Davis
Davis le 17 Mai 2024
Commenté : Torsten le 22 Mai 2024
For large vectors, the indices shown in a figure are a bit off. For example:
test = [zeros(1,1079998), 1, zeros(1,1457106-1079998), 1, zeros(1,2159999-1457108)];
find(test) % gives correct indices: 1079999 1457108
figure; plot(test)
% The labeling of the 1's in the plot using data tips give idices of 1080000 and 1457110
This is probably a numeric precision issue.

Réponses (1)

Torsten
Torsten le 17 Mai 2024
Modifié(e) : Torsten le 17 Mai 2024
My guess is that the x-axis has a resolution of 10.
  7 commentaires
Davis
Davis le 22 Mai 2024
Modifié(e) : Davis le 22 Mai 2024
I got the following response from Mathworks:
After initial investigation, the description matches our record and indicates this is likely a known bug. The potential reason is that the datatip is using "%g" as output format. I want to let you know that our development team is aware of this issue. We appreciate your effort in identifying and reporting issues to help us provide our users with better experience using MATLAB.
Meanwhile you could manually set the datatip output format with the following code:
test = [zeros(1,1079998), 1, zeros(1,1457106-1079998), 1, zeros(1,2159999-1457108)];
find(test) % gives correct indices: 1079999 1457108
figure;
p = plot(test)
p.DataTipTemplate.DataTipRows(1).Format ='%d'
Torsten
Torsten le 22 Mai 2024
Thank you for coming back and posting TMW's answer here.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by