Insert blank cells in a matrix

64 ビュー (過去 30 日間)
Emilio Pulli
Emilio Pulli 2021 年 11 月 30 日
コメント済み: Walter Roberson 2021 年 12 月 2 日
How can I replace all the NaN values of a matrix with a blank space?

採用された回答

Walter Roberson
Walter Roberson 2021 年 11 月 30 日
You cannot do that. Numeric matrices cannot have spaces in them.
You can convert the matrix into a cell array and put spaces into the cell array... but it is not clear why you would do that.
myCell = num2cell(MyMatrix);
myCell(isnan(MyMatrix)) = {' '}; %nan -> space
Now what?
  12 件のコメント
Emilio Pulli
Emilio Pulli 2021 年 12 月 2 日
編集済み: Emilio Pulli 2021 年 12 月 2 日
Ok perfect, it works! Really really thank you!
The last doubt: do you know how to replace a number that has a lower number of digits with respect to the other numbers in the matrix with the same number with zero digits in order to have the same format of the other numbers? For instance, if I have a “1” in a matrix where all the other numbers are decimal with 4 decimal digits, how can I transform it into “1.0000”?
Walter Roberson
Walter Roberson 2021 年 12 月 2 日
Use the version with compose and fmt

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by