Say I have an array that contains the following elements:
1.0e+14 *
1.3325 1.6485 2.0402 1.0485 1.2027 2.0615 1.7432 1.9709 1.4807 0.9012
Now, is there a way to grab 1.0e+14 *
(base and exponent) individually?
If I do arr(10)
, then this will return 9.0120e+13
instead of 0.9012e+14
.
Assuming the question is to grab any elements in the array with coefficient less than one. Is there a way to obtain 1.0e+14
, so that I could just do arr(i) < 1.0e+14
?
I assume you want string output.
Let a
denote the input numeric array. You can do it this way, if you don't mind using evalc
(a variant of eval
, which is considered bad practice):
s = evalc('disp(a)');
s = regexp(s, '[\de+-\.]+', 'match');
This produces a cell array with the desired strings.
Example:
>> a = [1.2e-5 3.4e-6]
a =
1.0e-04 *
0.1200 0.0340
>> s = evalc('disp(a)');
>> s = regexp(s, '[\de+-\.]+', 'match')
s =
'1.0e-04' '0.1200' '0.0340'