MATLAB Answers

How to define the format of number such as D22.12 or D19.12?

5 views (last 30 days)
Kun-Chi Wang
Kun-Chi Wang on 30 Jul 2019
Commented: Guillaume on 30 Jul 2019
I am studying a code in which a text is read like this one.
0.740000000000D+02 0.640625000000D+01 0.427553523606D-08-0.146805323186D+01
They are processed by the following code:
[IODE Crs delta_n M0] = parsef(current_line, {'D22.12' 'D19.12' 'D19.12' 'D19.12'});
where function "parsef" is defined as:
function varargout = parsef(input, format)
global input_
input_ = input;
varargout = getvals(1, format, 1);
clear global input_
return
After being processed by the above code, the result is
"IODE = 74, Crs = 6.40625, delta_n = 4.27553523606e-09 ,M0 = -1.46805323186," which is the same as the text that I want to read.
The question is that there is another text I wnat to read, which is as shown:
6.100000000000E+01-2.409687500000E+02 3.192632985979E-09 1.224491866258E-01
They are processed by the same code mentioned above.
The result is
"IODE = 6.1, Crs = 1, delta_n = 2, M0 = 9," which is not exactly the same as the text that I want to read.
I guess the problem is the definition of format in the code:
{'D22.12' 'D19.12' 'D19.12' 'D19.12'}
However, I don't really understand what {'D22.12' 'D19.12' 'D19.12' 'D19.12'} means, not to mention to revise them.
Does anyone have suggestions or resources that I can refer to?

  1 Comment

Guillaume
Guillaume on 30 Jul 2019
We would need the code for getvals
Have you tried replacing the D by E in that format cell array passed to parsef?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by