[英]Formatting legend to include exponent in Matlab
very simple question here that I can't find an answer to.. I know how to adjust the values in the axes but for the legend, I want to include the value of a certain number that's on the order of 1e6. 这是一个非常简单的问题,我找不到答案。.我知道如何调整轴上的值,但对于图例,我想包括一个大约为1e6的特定数字的值。 At the moment, the legend is printing out all digits instead of the exponent.
此刻,图例正在打印所有数字而不是指数。 How do I force it to print the exponential format?
如何强制它打印指数格式? So far, I have:
到目前为止,我有:
str1 = sprintf('Re = %2.2f', Re);
str2 = sprintf('D = %2.1f m', D);
legend(str1,str2,'Location','southeast');
And Re is a value being calculated higher up in the code and it is the one I want to force to print exponentially. Re是在代码中向上计算的值,它是我要强制以指数方式打印的值。
Any help would be really appreciated! 任何帮助将非常感激! Thanks in advance
提前致谢
Use e
fromat specifier instead: 使用
e
fromat说明符代替:
str1 = sprintf('Re = %2.2e', Re);
You can also use g
which will automatically choose between f
and e
based on the size of resulting string. 您也可以使用
g
,它会根据结果字符串的大小在f
和e
之间自动选择。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.