フィルターのクリア

How can I write the percentage symbol in a cell array with strings?

17 ビュー (過去 30 日間)
Dimitris Kokkinos
Dimitris Kokkinos 2014 年 12 月 29 日
回答済み: Star Strider 2014 年 12 月 29 日
I have a vector with decimal slope values(their accuracy varies).What I need is to create a cell array with these values as strings but in percentage format.
Lets say for example A=[0.05;0.12;0.062;0.13]
and what I need is
B=cell(4,10)
B{1}=('5%')
B{2}=('12%')
B{3}=('6.2%')
B{4}=('13%')
My code was B = cellstr(num2str(A(:,1)));
But this was enough before my need for percentage format.
The variable B is a part of script and I cannot do this manually. Thanks in advance for your time.

採用された回答

Star Strider
Star Strider 2014 年 12 月 29 日
Try this:
A=[0.05;0.12;0.062;0.13];
B = cellstr(num2str(100*A(:,1), '%g%%'));

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by