필터 지우기
필터 지우기

Index 1 Variable by another

조회 수: 3 (최근 30일)
Hillaryfor2016
Hillaryfor2016 2015년 4월 12일
댓글: Star Strider 2015년 4월 12일
Hi there!
I have 2 variables
if true
A = 1
2
NaN
4
end
B= 20
2
5
4
end
I want to remove the '5' from variable B by replacing it with a NaN (i.e. any NaN's in variable A result in a NaN in variable B
I understand this is a simple problem. I have researched but its been a long day Please help x

채택된 답변

Star Strider
Star Strider 2015년 4월 12일
Use ‘logical indexing’:
B(isnan(A)) = NaN
produces:
B =
20
2
NaN
4
  댓글 수: 2
Hillaryfor2016
Hillaryfor2016 2015년 4월 12일
Worked beautifully, thanks for the help!! x
Star Strider
Star Strider 2015년 4월 12일
My pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by