Hello!
I have a Vector that is similar to this:
A= [1; 2; 3; NaN; 5; NaN;]
I would like to replace each NaN with a text.
In the end it should look like this:
a=[1;2;3; 'Example'; 5; 'Example']
Thanks!

 採用された回答

Voss
Voss 2022 年 9 月 11 日

0 投票

A = [1; 2; 3; NaN; 5; NaN;];
a = num2cell(A);
a(isnan(A)) = {'Example'};
disp(a);
{[ 1]} {[ 2]} {[ 3]} {'Example'} {[ 5]} {'Example'}

1 件のコメント

Nico
Nico 2022 年 9 月 11 日
Fantastic! Thank you very much.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Type Conversion についてさらに検索

製品

リリース

R2022a

タグ

質問済み:

2022 年 9 月 11 日

コメント済み:

2022 年 9 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by