MATLAB Answers

getting numbers from a cell

1 view (last 30 days)
I want to get the numbers from the cell below and have them as a Matrix:
A =
'1.39675e-02 -2.58099e-01 -8.32728e-03 0.00000e+00 2.19518e+01 1.21930e-01 0.00000e+00 3.00000e-05 3.00000e+02 9.98200e+02 1.41117e-11 '
  1 Comment
Stephen Cobeldick
Stephen Cobeldick on 8 May 2021
More efficient than STR2NUM:
V = sscanf(A,'%f')
V = 11×1
0.0139675 -0.258099 -0.00832728 0 21.9518 0.12193 0 3e-05 300 998.2

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 7 May 2021
A = '1.39675e-02 -2.58099e-01 -8.32728e-03 0.00000e+00 2.19518e+01 1.21930e-01 0.00000e+00 3.00000e-05 3.00000e+02 9.98200e+02 1.41117e-11 ';
Anum = str2num(A)
Anum = 1×11
0.0140 -0.2581 -0.0083 0 21.9518 0.1219 0 0.0000 300.0000 998.2000 0.0000

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!