Search code examples
matlabscientific-notationoperation

Why won't the following operations work in Matlab


If input into a Matlab script, the following are deemed as unacceptable:

   i) 8.8*e-2  
   ii) 3.2e1.5 
   iii) 1.25e+005

But why doesn't i), ii) and iii) work? Is it because e is undefined?

I would have thought the reason for i) is because of the unnecessary *, but there is no * in either ii) or iii) and I believe they are also unacceptable.


Solution

  • i:

    >> 8.8*e-2
    Undefined function or variable 'e'. 
    

    This is self explanatory; you're asking to multiply with the * operator. It should be 8.8e-2


    ii:

     >> 3e1.5
     3e1.5
        ↑
    Error: Unexpected MATLAB expression.
    

    From Wikipedia (emphasis mine):

    Scientific notation (also referred to as scientific form or standard index form, or standard form in the UK) is a way of expressing numbers that are too big or too small to be conveniently written in decimal form. [...]

    In scientific notation, all numbers are written in the form m × 10^n (m times ten raised to the power of n), where the exponent n is an integer, and the coefficient m is any real number.

    You want to use

    >> 3*10^1.5
    ans =
       94.8683
    

    iii:

    >> 1.25e+005
    ans =
          125000
    

    What's the problem?


    2 ARE acceptable: 6,10 and .0

    Can you clarify this question? It doesn't seem to be about scientific notation.

    >> 6,10
    ans =
         6
    ans =
        10
    >> .0
    ans =
         0