Problem with multiple values on plot
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Catherine
le 28 Fév 2017
Commenté : David Goodmanson
le 28 Fév 2017
Hi guys, I am having problem with repeated values on my plot.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161157/image.jpeg)
Here is my code regarding the plot:
plot(L_value,Temp_Lfile)
title('Intensity profile','fontsize',18)
xlabel('Wavelength (nm)','fontsize',18)
ylabel('Intensity','fontsize',18)
set(gca,'fontsize',18)
[L_pks,L_locs] = findpeaks(Temp_Lfile);
L_val = L_value(L_locs);
text(L_val,L_pks,num2str(L_val),'fontsize',12);
Both my L_val and L_pks variables are only 1x8 matrix. So, there should only be 8 numbers on the plot. Which part of my code is incorrect?
Thanks guys!
2 commentaires
Réponse acceptée
David Goodmanson
le 28 Fév 2017
Modifié(e) : David Goodmanson
le 28 Fév 2017
Hello Catherine, The last line will probably work if changed to
text(L_val,L_pks,num2str(L_val'),'fontsize',12);
this is because num2str of a row vector is one long string, which gets reused every time. num2str of a column vector is a column matrix of shorter strings, so text cycles through them.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!