Hi, i am trying to delete NoValue from A without hardcoding so that i am only left with numbers and store them in Absorption vector but when i run the code it comes back exactly as it is, please help!!
조회 수: 4 (최근 30일)
이전 댓글 표시
A = 20.0872
16.1710
20.6179
17.9930
18.6397
16.5852
22.5673
21.0629
19.8378
19.9037
20.2171
21.6581
21.2016
NoValue
NoValue
NoValue
NoValue
NoValue
NoValue
NoValue
NoValue
NoValue
match = 'NoValue';
for Vec = 1:1:length(A)
DeleteValues = strcmp(A,match);
if DeleteValues > 0
newStr = erase(A,match)
Absorption = [newStr]
end
end
댓글 수: 0
채택된 답변
Cris LaPierre
2020년 3월 27일
The conditional of an if statement can only check one value at a time, yet deletedValues is a vector. For your if statement to work in the code you've written, you'd need to check one value at a time doing something like this.
if DeleteValues(Vec)
...
However, you don't need a for loop at all. Take advantage of MATLAB's ability to work with vectors.
A = [20.0872
16.1710
20.6179
17.9930
18.6397
16.5852
22.5673
21.0629
19.8378
19.9037
20.2171
21.6581
21.2016
"NoValue"
"NoValue"
"NoValue"
"NoValue"
"NoValue"
"NoValue"
"NoValue"
"NoValue"
"NoValue"];
z = "NoValue";
DeleteValues = strcmp(A,z);
Absorption = A(~DeleteValues)
댓글 수: 6
Cris LaPierre
2020년 3월 27일
We must be missing something. This script is just a text file of numbers. Running it shouldn't do anything. I actually get an error.
Is there some companion code that somehow captures these values? How do they get used in your script?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Algebra에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!