フィルターのクリア

for loop and if else statement? it is not working with the different angle. could you please suggest me some solution

1 回表示 (過去 30 日間)
for i=1:size(angle)
if(angle(i) >= 1 || angle(i)<= 9)
v1(i) =v0(i)*(1-deficit1); %affected by the x away one% downstream wind for turbine 2nd
v2(i) =v1(i)*(1-deficit2); %affected by the x away one% downstream wind for turbine 2nd
v3(i) =v2(i)*(1-deficit3); %affected by the x away one% downstream wind for turbine 2nd
else
end
if(angle(i) >=10 || angle(i) <=170)
v1(i) =v0(i);
v2(i) =v0(i);
v3(i) =v0(i);
else
end
if(angle(i) >= 171 || angle(i)<= 189)
v1(i)=v0(i)*(1-deficit2); %affected by the x away one% downstream wind for turbine 2nd
v2(i)=v1(i)*(1-deficit1); %affected by the x away one% downstream wind for turbine 2nd
% v3(i)=v2(i)*(1-deficit3) %affected by the x away one% downstream wind for turbine 2nd
else
end
if(angle(i) >=190 || angle(i) <=350)
v1(i) =v0(i);
v2(i) =v0(i);
v3(i) =v0(i);
else
end
if(angle(i) >= 351 || angle(i)<= 360)
v1(i)=v0(i)*(1-deficit2); %affected by the x away one% downstream wind for turbine 2nd
v2(i)=v1(i)*(1-deficit1); %affected by the x away one% downstream wind for turbine 2nd
% v3(i)=v2(i)*(1-deficit3) %affected by the x away one% downstream wind for turbine 2nd
else
end
end

採用された回答

Walter Roberson
Walter Roberson 2019 年 5 月 3 日
You should be using && rather than || for those tests.
Also remember that if you are dealing with floating point numbers, that (say) 9.2 is not <= 9 and is not >= 10 and so would not match any of your conditions.
if angle(i) < 1
ummm, what? angle is negative or between 0 and 1
elseif angle(i) < 10
1 inclusive to 10 exclusive case
elseif angle(i) < 170
10 inclusive to 170 exclusive case
elseif angle(i) <= 190
170 inclusive to 190 inclusive case
elseif angle(i) < 350
190 exclusive to 350 exclusive case
elseif angle(i) <= 360
350 inclusive to 360 inclusive case
else
ummm, what? angle is greater than 360 or is nan
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDiscrete Data Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by