如何在Matlab中获得科学记数法的指数 [英] How to get Exponent of Scientific Notation in Matlab

查看:51
本文介绍了如何在Matlab中获得科学记数法的指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当数字非常小时,Matlab 会自动以科学记数法格式显示它们.

When the numbers are really small, Matlab automatically shows them formatted in Scientific Notation.

示例:

A = rand(3) / 10000000000000000;

A =

  1.0e-016 *

    0.6340    0.1077    0.6477
    0.3012    0.7984    0.0551
    0.5830    0.8751    0.9386

是否有一些内置函数可以返回指数?类似于:getExponent(A) = -16?

Is there some in-built function which returns the exponent? Something like: getExponent(A) = -16?

我知道这是一个愚蠢的问题,但我需要检查数百个矩阵,但我似乎无法弄清楚.

I know this is sort of a stupid question, but I need to check hundreds of matrices and I can't seem to figure it out.

感谢您的帮助.

推荐答案

基础数学可以告诉你:

floor(log10(N))

一个数以 10 为底的对数告诉您该数中小数点前大约有多少位数字.

The log base 10 of a number tells you approximately how many digits before the decimal are in that number.

例如99987123459823754就是9.998E+016

log10(99987123459823754)16.9999441,它的底数是16 - 基本上可以告诉你科学记数法中的指数是16 英寸,非常接近 17 英寸.

log10(99987123459823754) is 16.9999441, the floor of which is 16 - which can basically tell you "the exponent in scientific notation is 16, very close to being 17".

Floor 总是向下取整,因此您无需担心小指数:

Floor always rounds down, so you don't need to worry about small exponents:

0.000000000003754 = 3.754E-012
log10(0.000000000003754) = -11.425
floor(log10(0.000000000003754)) = -12

这篇关于如何在Matlab中获得科学记数法的指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆