Replacing NaN with char

조회 수: 12 (최근 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'}
  댓글 수: 1
Nico
Nico 2022년 9월 11일
Fantastic! Thank you very much.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by