How to edit a cell to include a parantheses

2 次查看(过去 30 天)
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?

回答(1 个)

Azzi Abdelmalek
Azzi Abdelmalek 2013-3-24
编辑:Azzi Abdelmalek 2013-3-24
fprintf('(%.4f)\n',B)
  3 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2013-3-24
编辑:Azzi Abdelmalek 2013-3-24
copy and paste
B=7.511502463068333e-04;
fprintf('(%.4f)\n',B)
Walter Roberson
Walter Roberson 2013-3-24
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by