Filter löschen
Filter löschen

Number of decimal places for Matrix Entry

6 Ansichten (letzte 30 Tage)
Joe
Joe am 16 Jan. 2014
Kommentiert: Walter Roberson am 17 Jan. 2014
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 Kommentare
Azzi Abdelmalek
Azzi Abdelmalek am 16 Jan. 2014
post an example
Joe
Joe am 17 Jan. 2014
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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 16 Jan. 2014
What is a "Matrix" for this purpose?
What format are you using with fprintf() ?
fprintf('%.999g\n', pi)
  2 Kommentare
Joe
Joe am 17 Jan. 2014
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 am 17 Jan. 2014
>> 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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by