changing format of number displayed on figure
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have 2 sets of data 'a' and 'b' which I have plotted in a figure. I've then integrated under this curve using 'trapz' and then displaying this result on the figure. This is all successful however I want to change the format of the displayed number to scientific notation instead of a long number. I've used 'format longEng' but this is unsuccessful. (This is all within a for loop).
------
plot(x,y);
xlabel('x data')
ylabel('y data');
legend('Background Corrected');
title(figure_caption);
set(gca, 'YScale', 'log');
format longEng;
integration2 = trapz(x, y);
integration_text2 = 'curve integration =';
integration_info2 = [integration_text2, ' ', num2str(integration2)];
disp(integration_info2);
dim = [0 0.95 0.05 0.05];
annotation('textbox', dim, 'String', integration_info2, 'FitBoxToText', 'on');
end
------
thanks
1 commentaire
Réponse acceptée
Steven Lord
le 5 Avr 2018
The format function affects only how numeric arrays are displayed in the Command Window. To affect how they are written to a char vector or string that you can use as the String property of a graphics object, use sprintf or specify a precision or format specifier as the second input to the num2str function. See the documentation pages for those functions for examples.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Text Data Preparation 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!