Vass
Vass

Reputation: 2820

In Matlab how to use variables for the numbers in scientific notation (matissa and exponent)?

I am using Matlab and using numbers in scientific notation, which are represented with the letter e for the exponent. An example in Matlab:

>> 2e5
ans =
200000

Now would like to work with numbers in scientific notation, but using variables to hold the values of the mantissa and the exponent (left and right side of the e respectively). I do not understand how this can be done without the variable names merging with the letter e for the exponent. Eg:

>> rr=5;
>> 2err
??? 2err
|
Error: Unexpected MATLAB operator.

Can this still be done? Or must I use the manual approach:

>> 2*10^rr
ans =
200000

Upvotes: 3

Views: 26682

Answers (1)

Sam Roberts
Sam Roberts

Reputation: 24127

You must use the manual approach; you can't use scientific notation like that with variables. You might want to use 2.*10.^rr, with the ., to enable you to use the same statement with arrays of numbers.

Upvotes: 3

Related Questions