Number of decimal places for Matrix Entry

1 次查看(过去 30 天)
I want to increase the number of decimal places a figure can accurately be shown in an entry of a Matrix, using fprintf it shows all entries up to 4dp but how can I increase the d.p?
Thanks
Joe
  2 个评论
Joe
Joe 2014-1-17
Say A is the matrix fprintf('%10.7f',X) I understand 10 to be the spacing -character width and 7 related to the dp but the matrix i get is only to 4d.p.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2014-1-16
What is a "Matrix" for this purpose?
What format are you using with fprintf() ?
fprintf('%.999g\n', pi)
  2 个评论
Joe
Joe 2014-1-17
Say A is the matrix fprintf('%10.7f',X) I understand 10 to be the spacing -character width and 7 related to the dp but the matrix i get is only to 4d.p.
Walter Roberson
Walter Roberson 2014-1-17
>> fprintf('%10.7f\n', pi)
3.1415927
Is what you are doing like
A = fprintf('%10.7f', pi);
If it is then what is being stored in A is the number of elements output, not the string. If you want the string use sprintf
A = sprintf('%10.7f', pi);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by