필터 지우기
필터 지우기

Setting an array of a vector = NaN

조회 수: 1 (최근 30일)
Christoph Meier
Christoph Meier 2015년 9월 11일
댓글: Star Strider 2015년 9월 11일
Dear Matlab community,
I am trying to set a certain array within a vector = NaN
Example:
If I have a vector with a dimension 9,1:
0.0001
0.0003
0.0001
0.0002
2
3
4
5
6
And I would like to set the elements 1-4 = NaN, to get the following output:
NaN
NaN
NaN
NaN
2
3
4
5
6
Does someone know how to set an array within the vector to NaNs? In this case, I know that element 1-4 should be NaNs.
Thank you very much!
Chris

채택된 답변

Star Strider
Star Strider 2015년 9월 11일
This will do what you want:
V = [0.0001
0.0003
0.0001
0.0002
2
3
4
5
6];
V(V<1) = NaN
  댓글 수: 4
Christoph Meier
Christoph Meier 2015년 9월 11일
I found a solution to the problem myself, and I will share for other users:
Setting a specific array within a vector = NaN, or any other value for that purpose:
V = [0.0001
0.0003
0.0001
0.0002
2
3
4
5
6];
V(1:4) = NaN
V = [NaN
NaN
NaN
NaN
2
3
4
5
6];
Thank you, Star Strider!
Star Strider
Star Strider 2015년 9월 11일
My pleasure.
I thought you wanted to set specific conditions on what elements became NaN.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 NaNs에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by