How to fix a number equal to null in MATLAB

조회 수: 1 (최근 30일)
Nisar Ahmed
Nisar Ahmed 2020년 8월 13일
댓글: Nisar Ahmed 2020년 8월 13일
Hello
I have a lot values (equal to -999.25) in my data columns. I want that matlab read these values (-999.25) as zero when ever I load or run my data on MATLAB. How can I fix this problem? Please help

채택된 답변

源樹 上林
源樹 上林 2020년 8월 13일
a = [ 1 2 3 -999.25 -999.25 4 5]
a(a == -999.25) = 0
  댓글 수: 7
Walter Roberson
Walter Roberson 2020년 8월 13일
DTP = clew(DTP);
DRZ = clew(DRZ) ;
function A = clew(A)
A(A==-999.25) = nan;
So you would have 10 lines of assignment, one for each variable.
Yes it is possible to do it in fewer lines with more confusing code.
But better would have been to store all of the arrays in the same variable, such as a multidimensional array or cell array or struct. Any of those could have all fields processed easily, like
Dats = structfun(@clew, Dats, 'uniform', 0)
Nisar Ahmed
Nisar Ahmed 2020년 8월 13일
Roberson,
Thanks

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by