changing format of number displayed on figure
17 次查看(过去 30 天)
显示 更早的评论
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
采纳的回答
Steven Lord
2018-4-5
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!