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

StackOverflow https://stackoverflow.com//questions/9655668

  •  11-12-2019
  •  | 
  •  

문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top