How to edit a cell to include a parantheses

I have a number 7.511502463068333e-04. I want to put it in a cell. I used :
B=[7.511502463068333e-04];
A=num2cell(B);
however i want the number to be in parentheses as a 4 decimal point number. i.e. i want it to appear as:
A='(0.0008)';
How can i do that?

Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 24 Mär. 2013
Bearbeitet: Azzi Abdelmalek am 24 Mär. 2013

1 Stimme

fprintf('(%.4f)\n',B)

3 Kommentare

joseph Frank
joseph Frank am 24 Mär. 2013
it is not working. I tried A=fprintf('(%.4f)\n',B); it gave me 9
Azzi Abdelmalek
Azzi Abdelmalek am 24 Mär. 2013
Bearbeitet: Azzi Abdelmalek am 24 Mär. 2013
copy and paste
B=7.511502463068333e-04;
fprintf('(%.4f)\n',B)
A = sprintf('(%.4f)', B);
Or
A = num2str(B, '(%.4f)');
Note: num2cell() is for converting arrays into cell arrays, not for changing them into character format.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange

Produkte

Tags

Gefragt:

am 24 Mär. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by