Replacing NaN with char

3 次查看(过去 30 天)
Nico
Nico 2022-9-11
评论: Nico 2022-9-11
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
A = [1; 2; 3; NaN; 5; NaN;];
a = num2cell(A);
a(isnan(A)) = {'Example'};
disp(a);
{[ 1]} {[ 2]} {[ 3]} {'Example'} {[ 5]} {'Example'}

更多回答(0 个)

类别

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

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by