If condition whit exceed condition

Given the arrays
WEEK = [148 179 102 242 242 268 156 162 267 267 273 273 268];
BDR = [210 210 210 210 210 210 210 210 210 210 210 210 210];
AG= [42 42 42 42 42 42 42 42 42 42 42 42 42];
NEXTpro= [32 12 34 15 15 20 32 41 40 22 22 23 25];
and thecode
if i==1
Y=NEXTpro
elseif i==2
Y= NEXTpro
else
SETT1 = WEEK(1:numel(BDR));
Y=NEXTpro
Y = Y(1:numel(BDR));
idxy = SETT1 <= BDR;
Y=Y.*idxy
end
When i>2 I analyze the two arrays WEEK adn BDR. If an element in WEEK exceed a value in BDR (considering the same column) then in the array Y I insert zero in the element of the same column. Obtaining
Y = [32 12 34 0 0 0 32 41 0 0 0 0 0];
In reality if the exceed condition is verified I want that
Y=AG.*idxy
but I cannot simply substitute this insid the code, otherwise when the condition is not satisfied I consider always AG instead of NEXTpro.obtaining
Y = [42 42 42 0 0 0 42 42 0 0 0 0 0];
How can I modify the code to get what I want?

4 个评论

What results "Y" you are expected?
Do not consider the if cycle if you want.
JUST TAKE
SETT1 = WEEK(1:numel(BDR));
Y=NEXTpro
Y = Y(1:numel(BDR));
idxy = SETT1 <= BDR;
Y=Y.*idxy
With this I want
If the exceed conditon is not satisfied
Y = [32 12 34 15 15 20 32 41 40 22 22 23 25]; %that is NEXTpro
else
Y = [42 42 42 0 0 0 42 42 0 0 0 0 0];
I have deleted the answer, so other can answere the question.
Hi,
Can you please elaborate on what are the different conditions and what results do you expect, and what do you mean by "exceed condition"?

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

产品

版本

R2019b

标签

提问:

2019-10-17

评论:

2019-10-22

Community Treasure Hunt

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

Start Hunting!

Translated by