Replacing NaN with char

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!

 Risposta accettata

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

Più risposte (0)

Categorie

Prodotti

Release

R2022a

Tag

Richiesto:

il 11 Set 2022

Commentato:

il 11 Set 2022

Community Treasure Hunt

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

Start Hunting!

Translated by