I am not sure why my if statement code is not working

조회 수: 1 (최근 30일)
NCA
NCA 2021년 5월 26일
답변: KSSV 2021년 5월 26일
I have this code which omits the first two conditions and executes the last one , can you please have a look as I have tried it a few times without success. Thank You
y=SULPHUR(:,2);
x=table2array(y);
x(isnan(x)) = [];
for i=1:length(x)
if x > 0.5000
disp('HSFO');
elseif x >= 0.1000 & x<=0.5000
disp('VLSFO');
else
disp('ULSFO')
end
end

채택된 답변

KSSV
KSSV 2021년 5월 26일
x is an array and you are comapring it with a scalar.
x=SULPHUR(:,2);
x(isnan(x)) = [];
for i=1:length(x)
if x(i) > 0.5000
disp('HSFO');
elseif x(i) >= 0.1000 & x(i)<=0.5000
disp('VLSFO');
else
disp('ULSFO')
end
end

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by