フィルターのクリア

Transfer from Decimal to Percentage?

14 ビュー (過去 30 日間)
Xiao Tang
Xiao Tang 2012 年 6 月 25 日
コメント済み: geopap 2016 年 9 月 14 日
Hi guys,
I have a Matrix A =
[1 2 3
4 5 6
7 8 9]
How I can get Matrix B =
[100% 200% 300%
400% 500% 600%
700% 800% 900%]?
Sprintf might work but I don't know how to use it. Thanks in advance.
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 6 月 25 日
You cannot get it as a numeric matrix, as numeric matrices cannot contain '%' characters.
Xiao Tang
Xiao Tang 2012 年 6 月 25 日
Then how can I transfer it to string or cell array? As long as there follows '%'.
I was wondering if there is a function to do this...

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 25 日
thisfmt = [ repmat(' %.3f%%', 1, size(A,2)) '\n'];
B = sprintf( thisfmt, A.' );
B(1) = '[';
B(end) = ']';
This creates the output as a single string.
  8 件のコメント
Xiao Tang
Xiao Tang 2012 年 6 月 27 日
Thanks Tom! That's perfect!
geopap
geopap 2016 年 9 月 14 日
Tom this works great!! Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by