Replacing NaN with char

3 Ansichten (letzte 30 Tage)
Nico
Nico am 11 Sep. 2022
Kommentiert: Nico am 11 Sep. 2022
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!

Akzeptierte Antwort

Voss
Voss am 11 Sep. 2022
A = [1; 2; 3; NaN; 5; NaN;];
a = num2cell(A);
a(isnan(A)) = {'Example'};
disp(a);
{[ 1]} {[ 2]} {[ 3]} {'Example'} {[ 5]} {'Example'}
  1 Kommentar
Nico
Nico am 11 Sep. 2022
Fantastic! Thank you very much.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by